// $ANTLR 3.1.2 C:\\work\\simsharp\\Src\\Ssc\\SimSharpGen.g 2009-08-08 11:13:31

// The variable 'variable' is assigned but its value is never used.
#pragma warning disable 168, 219
// Unreachable code detected.
#pragma warning disable 162

//Parser Header	
using SscLib;
using System.Collections.Generic;
using System.Reflection.Emit;


using System;
using Antlr.Runtime;
using Antlr.Runtime.Tree;using IList 		= System.Collections.IList;
using ArrayList 	= System.Collections.ArrayList;
using Stack 		= Antlr.Runtime.Collections.StackList;

using IDictionary	= System.Collections.IDictionary;
using Hashtable 	= System.Collections.Hashtable;

public partial class SimSharpGen : TreeParser
{
    public static readonly string[] tokenNames = new string[] 
	{
        "<invalid>", 
		"<EOR>", 
		"<DOWN>", 
		"<UP>", 
		"SimulaSourceModule", 
		"Program", 
		"Block", 
		"SubBlock", 
		"BlockHead", 
		"Declaration", 
		"VarDecl", 
		"Type", 
		"TypeList", 
		"ConstElement", 
		"Variable", 
		"LitteralNum", 
		"Statement", 
		"CompoundTail", 
		"CompoundStatement", 
		"ActualParameters", 
		"Source", 
		"Destination", 
		"RemoteAccess", 
		"MethOrArrayParams", 
		"Identifier", 
		"MethCall", 
		"ConnectBlock1", 
		"ConnectBlock2", 
		"ProcDecl", 
		"ProcBody", 
		"FormalParameters", 
		"Specification", 
		"ForRightPart", 
		"StepListElement", 
		"WhileListElement", 
		"Unary", 
		"ClassDecl", 
		"ClassBody", 
		"RemoteAssign", 
		"ArrayDecl", 
		"Array", 
		"ArrayDim", 
		"IdentList", 
		"Prolog", 
		"Epilog", 
		"AndThen", 
		"OrElse", 
		"Label", 
		"GoTo", 
		"LabelDesignator", 
		"SwitchDesignator", 
		"SwitchList", 
		"PrefixedBlock", 
		"PLUS", 
		"MINUS", 
		"TIMES", 
		"DIV", 
		"INTDIV", 
		"EXP", 
		"CONCAT", 
		"LONGEXP", 
		"REFEQ", 
		"REFNEQ", 
		"SCOLON", 
		"COLON", 
		"LPAR", 
		"RPAR", 
		"DOT", 
		"COMMA", 
		"VALASSIGN", 
		"REFASSIGN", 
		"EXTERNAL", 
		"PROCEDURE", 
		"ID", 
		"IS", 
		"CLASS", 
		"EQ", 
		"STRING", 
		"ACTIVATE", 
		"REACTIVATE", 
		"BEFORE", 
		"AFTER", 
		"PRIOR", 
		"AT", 
		"DELAY", 
		"ELSE", 
		"IF", 
		"THEN", 
		"WHILE", 
		"DO", 
		"FOR", 
		"STEP", 
		"UNTIL", 
		"GOTO", 
		"GO", 
		"TO", 
		"INSPECT", 
		"WHEN", 
		"OTHERWISE", 
		"BEGIN", 
		"END", 
		"ARRAY", 
		"SWITCH", 
		"LABEL", 
		"NAME", 
		"VALUE", 
		"INNER", 
		"VIRTUAL", 
		"HIDDEN", 
		"PROTECTED", 
		"OR", 
		"AND", 
		"EQV", 
		"IMP", 
		"NOT", 
		"IN", 
		"LT", 
		"LE", 
		"GE", 
		"GT", 
		"NE", 
		"QUA", 
		"NONE", 
		"NUM_INT", 
		"NUM_REAL", 
		"NOTEXT", 
		"CHARCONST", 
		"NEW", 
		"THIS", 
		"BOOLEAN", 
		"CHARACTER", 
		"INTEGER", 
		"SHORT", 
		"REAL", 
		"LONG", 
		"TEXT", 
		"REF", 
		"TRUE", 
		"FALSE", 
		"A", 
		"C", 
		"T", 
		"I", 
		"V", 
		"E", 
		"F", 
		"R", 
		"N", 
		"D", 
		"Y", 
		"B", 
		"O", 
		"G", 
		"L", 
		"H", 
		"S", 
		"M", 
		"COMMENT", 
		"Q", 
		"X", 
		"P", 
		"W", 
		"U", 
		"LETTER", 
		"DIGIT", 
		"RADIX", 
		"RADIXDIGIT", 
		"DECIMALNUMBER", 
		"EXPONENTPART", 
		"CHAR", 
		"COMM", 
		"WHITESPACE", 
		"DECIMALFRAC", 
		"J", 
		"K", 
		"Z"
    };

    public const int EXTERNAL = 71;
    public const int ProcBody = 29;
    public const int LT = 116;
    public const int WHILE = 88;
    public const int Array = 40;
    public const int Specification = 31;
    public const int LETTER = 163;
    public const int CHAR = 169;
    public const int NEW = 127;
    public const int DO = 89;
    public const int WhileListElement = 34;
    public const int NOT = 114;
    public const int ClassBody = 37;
    public const int EOF = -1;
    public const int CHARACTER = 130;
    public const int Identifier = 24;
    public const int NAME = 104;
    public const int Variable = 14;
    public const int LPAR = 65;
    public const int EXP = 58;
    public const int Declaration = 9;
    public const int NUM_REAL = 124;
    public const int MethCall = 25;
    public const int BEGIN = 99;
    public const int Unary = 35;
    public const int THIS = 128;
    public const int IMP = 113;
    public const int RADIX = 165;
    public const int EQ = 76;
    public const int GOTO = 93;
    public const int COMMENT = 157;
    public const int ForRightPart = 32;
    public const int VIRTUAL = 107;
    public const int REFNEQ = 62;
    public const int ARRAY = 101;
    public const int OTHERWISE = 98;
    public const int NE = 120;
    public const int D = 148;
    public const int E = 144;
    public const int GE = 118;
    public const int F = 145;
    public const int G = 152;
    public const int A = 139;
    public const int B = 150;
    public const int C = 140;
    public const int L = 153;
    public const int CONCAT = 59;
    public const int M = 156;
    public const int StepListElement = 33;
    public const int N = 147;
    public const int O = 151;
    public const int H = 154;
    public const int SWITCH = 102;
    public const int I = 142;
    public const int J = 173;
    public const int ELSE = 85;
    public const int K = 174;
    public const int U = 162;
    public const int T = 141;
    public const int WHITESPACE = 171;
    public const int W = 161;
    public const int V = 143;
    public const int QUA = 121;
    public const int Q = 158;
    public const int P = 160;
    public const int S = 155;
    public const int R = 146;
    public const int VALUE = 105;
    public const int Y = 149;
    public const int MethOrArrayParams = 23;
    public const int X = 159;
    public const int Block = 6;
    public const int Z = 175;
    public const int REAL = 133;
    public const int GoTo = 48;
    public const int BlockHead = 8;
    public const int REACTIVATE = 79;
    public const int UNTIL = 92;
    public const int DECIMALFRAC = 172;
    public const int INSPECT = 96;
    public const int NONE = 122;
    public const int NUM_INT = 123;
    public const int OR = 110;
    public const int GT = 119;
    public const int VALASSIGN = 69;
    public const int GO = 94;
    public const int END = 100;
    public const int FALSE = 138;
    public const int ConstElement = 13;
    public const int Label = 47;
    public const int SubBlock = 7;
    public const int NOTEXT = 125;
    public const int RADIXDIGIT = 166;
    public const int Destination = 21;
    public const int SwitchDesignator = 50;
    public const int DELAY = 84;
    public const int PROTECTED = 109;
    public const int CLASS = 75;
    public const int Epilog = 44;
    public const int INNER = 106;
    public const int INTDIV = 57;
    public const int PrefixedBlock = 52;
    public const int ProcDecl = 28;
    public const int SimulaSourceModule = 4;
    public const int STEP = 91;
    public const int FOR = 90;
    public const int LitteralNum = 15;
    public const int VarDecl = 10;
    public const int ID = 73;
    public const int AND = 111;
    public const int AndThen = 45;
    public const int Program = 5;
    public const int ActualParameters = 19;
    public const int IF = 86;
    public const int TypeList = 12;
    public const int AT = 83;
    public const int ConnectBlock1 = 26;
    public const int ConnectBlock2 = 27;
    public const int BOOLEAN = 129;
    public const int THEN = 87;
    public const int IN = 115;
    public const int RemoteAssign = 38;
    public const int COMMA = 68;
    public const int IS = 74;
    public const int CompoundTail = 17;
    public const int ArrayDim = 41;
    public const int CompoundStatement = 18;
    public const int Source = 20;
    public const int PLUS = 53;
    public const int REFEQ = 61;
    public const int SwitchList = 51;
    public const int DIGIT = 164;
    public const int DOT = 67;
    public const int Prolog = 43;
    public const int FormalParameters = 30;
    public const int IdentList = 42;
    public const int SCOLON = 63;
    public const int INTEGER = 131;
    public const int Type = 11;
    public const int ArrayDecl = 39;
    public const int Statement = 16;
    public const int TO = 95;
    public const int ACTIVATE = 78;
    public const int LabelDesignator = 49;
    public const int ClassDecl = 36;
    public const int BEFORE = 80;
    public const int SHORT = 132;
    public const int LONGEXP = 60;
    public const int COMM = 170;
    public const int AFTER = 81;
    public const int MINUS = 54;
    public const int TEXT = 135;
    public const int OrElse = 46;
    public const int TRUE = 137;
    public const int PROCEDURE = 72;
    public const int REFASSIGN = 70;
    public const int REF = 136;
    public const int COLON = 64;
    public const int DECIMALNUMBER = 167;
    public const int EXPONENTPART = 168;
    public const int LABEL = 103;
    public const int WHEN = 97;
    public const int HIDDEN = 108;
    public const int RemoteAccess = 22;
    public const int RPAR = 66;
    public const int EQV = 112;
    public const int DIV = 56;
    public const int TIMES = 55;
    public const int LONG = 134;
    public const int LE = 117;
    public const int PRIOR = 82;
    public const int STRING = 77;
    public const int CHARCONST = 126;

    // delegates
    // delegators



        public SimSharpGen(ITreeNodeStream input)
    		: this(input, new RecognizerSharedState()) {
        }

        public SimSharpGen(ITreeNodeStream input, RecognizerSharedState state)
    		: base(input, state) {
            InitializeCyclicDFAs();

             
        }
        

    override public string[] TokenNames {
		get { return SimSharpGen.tokenNames; }
    }

    override public string GrammarFileName {
		get { return "C:\\work\\simsharp\\Src\\Ssc\\SimSharpGen.g"; }
    }


    //Parser Members
    SymbolTable symTab;
    Context ctx;
    bool loadAsObject;
    bool loadByRef;
    bool valAssign;
    CodeGen cg;

        public SscLib.IErrorManager errMan;
        
        public override void DisplayRecognitionError(string[] tokenNames, RecognitionException e)
        {
            string header = base.GetErrorHeader(e);
            string message = base.GetErrorMessage(e, tokenNames);
            errMan.ReportError("CodeGen", header, message, tokenNames, e);
        }
        
        private void Dummy(SimSharpTreeNode node)
        {
        	int i =0;
        }
        
        private void Dummy2(object o)
        {
        int i = 0;
        }
        
        bool IsMethod(string name)
        {
          Symbol s = ctx.Scope.ResolveMethod(name);
          return (s!=null);
        }
        
        bool IsArray(string name)
        {
          TypeSymbol t = ctx.Scope.ResolveType(name);
          if (t == null) return false;
          return t.IsArray;
        }



    // $ANTLR start "begin"
    // C:\\work\\simsharp\\Src\\Ssc\\SimSharpGen.g:62:1: begin[SymbolTable st, CodeGen cg] : ^( SimulaSourceModule program ) ;
    public void begin(SymbolTable st, CodeGen cg) // throws RecognitionException [1]
    {   

        this.symTab = st;
        this.ctx = cg.Context;
        this.ctx.Push(st.TopScope);
        this.cg = cg;

        try 
    	{
            // C:\\work\\simsharp\\Src\\Ssc\\SimSharpGen.g:69:2: ( ^( SimulaSourceModule program ) )
            // C:\\work\\simsharp\\Src\\Ssc\\SimSharpGen.g:69:4: ^( SimulaSourceModule program )
            {
            	Match(input,SimulaSourceModule,FOLLOW_SimulaSourceModule_in_begin85); if (state.failed) return ;

            	Match(input, Token.DOWN, null); if (state.failed) return ;
            	PushFollow(FOLLOW_program_in_begin87);
            	program();
            	state.followingStackPointer--;
            	if (state.failed) return ;

            	Match(input, Token.UP, null); if (state.failed) return ;

            }

        }
        catch (RecognitionException re) 
    	{
            ReportError(re);
            Recover(input,re);
        }
        finally 
    	{
        }
        return ;
    }
    // $ANTLR end "begin"


    // $ANTLR start "program"
    // C:\\work\\simsharp\\Src\\Ssc\\SimSharpGen.g:72:1: program : ^( Program programBody ) ;
    public void program() // throws RecognitionException [1]
    {   
        SimSharpTreeNode Program1 = null;

        try 
    	{
            // C:\\work\\simsharp\\Src\\Ssc\\SimSharpGen.g:72:9: ( ^( Program programBody ) )
            // C:\\work\\simsharp\\Src\\Ssc\\SimSharpGen.g:72:11: ^( Program programBody )
            {
            	Program1=(SimSharpTreeNode)Match(input,Program,FOLLOW_Program_in_program102); if (state.failed) return ;

            	if ( (state.backtracking==0) )
            	{

            	  	  	ProgramSymbol prog = Program1.Symbol as ProgramSymbol;
            	  	  	//cg.CreateMetadata(prog);
            	  	  	ctx.Push(prog);
            	  		
            	  	  	CtorSymbol ctor = prog.GetCtor();
            	  	  	//cg.CreateMetadata(ctor);
            	  	  	ctx.Push(ctor);
            	  	  	
            	}

            	Match(input, Token.DOWN, null); if (state.failed) return ;
            	PushFollow(FOLLOW_programBody_in_program113);
            	programBody();
            	state.followingStackPointer--;
            	if (state.failed) return ;
            	if ( (state.backtracking==0) )
            	{
            	   
            	  		 cg.ReturnFromProc(); 
            	  		 ctx.Pop(); //Ctor
            	  		 ctx.Pop(); //Program class
            	  		
            	}

            	Match(input, Token.UP, null); if (state.failed) return ;

            }

        }
        catch (RecognitionException re) 
    	{
            ReportError(re);
            Recover(input,re);
        }
        finally 
    	{
        }
        return ;
    }
    // $ANTLR end "program"


    // $ANTLR start "programBody"
    // C:\\work\\simsharp\\Src\\Ssc\\SimSharpGen.g:91:1: programBody : ( block | compoundStatement );
    public void programBody() // throws RecognitionException [1]
    {   
        try 
    	{
            // C:\\work\\simsharp\\Src\\Ssc\\SimSharpGen.g:92:2: ( block | compoundStatement )
            int alt1 = 2;
            int LA1_0 = input.LA(1);

            if ( (LA1_0 == Block) )
            {
                alt1 = 1;
            }
            else if ( (LA1_0 == CompoundStatement) )
            {
                alt1 = 2;
            }
            else 
            {
                if ( state.backtracking > 0 ) {state.failed = true; return ;}
                NoViableAltException nvae_d1s0 =
                    new NoViableAltException("", 1, 0, input);

                throw nvae_d1s0;
            }
            switch (alt1) 
            {
                case 1 :
                    // C:\\work\\simsharp\\Src\\Ssc\\SimSharpGen.g:92:4: block
                    {
                    	PushFollow(FOLLOW_block_in_programBody134);
                    	block();
                    	state.followingStackPointer--;
                    	if (state.failed) return ;

                    }
                    break;
                case 2 :
                    // C:\\work\\simsharp\\Src\\Ssc\\SimSharpGen.g:93:4: compoundStatement
                    {
                    	PushFollow(FOLLOW_compoundStatement_in_programBody139);
                    	compoundStatement();
                    	state.followingStackPointer--;
                    	if (state.failed) return ;

                    }
                    break;

            }
        }
        catch (RecognitionException re) 
    	{
            ReportError(re);
            Recover(input,re);
        }
        finally 
    	{
        }
        return ;
    }
    // $ANTLR end "programBody"


    // $ANTLR start "statement"
    // C:\\work\\simsharp\\Src\\Ssc\\SimSharpGen.g:96:1: statement : ( block | prefixedBlock | valueAssignment | refAssignment[false] | procStatement | connection | compoundStatement | condition | whileStatement | forStatement | objectGenStatement | gotoStatement | labelStatement );
    public void statement() // throws RecognitionException [1]
    {   
        try 
    	{
            // C:\\work\\simsharp\\Src\\Ssc\\SimSharpGen.g:97:2: ( block | prefixedBlock | valueAssignment | refAssignment[false] | procStatement | connection | compoundStatement | condition | whileStatement | forStatement | objectGenStatement | gotoStatement | labelStatement )
            int alt2 = 13;
            alt2 = dfa2.Predict(input);
            switch (alt2) 
            {
                case 1 :
                    // C:\\work\\simsharp\\Src\\Ssc\\SimSharpGen.g:97:4: block
                    {
                    	PushFollow(FOLLOW_block_in_statement151);
                    	block();
                    	state.followingStackPointer--;
                    	if (state.failed) return ;

                    }
                    break;
                case 2 :
                    // C:\\work\\simsharp\\Src\\Ssc\\SimSharpGen.g:98:4: prefixedBlock
                    {
                    	PushFollow(FOLLOW_prefixedBlock_in_statement156);
                    	prefixedBlock();
                    	state.followingStackPointer--;
                    	if (state.failed) return ;

                    }
                    break;
                case 3 :
                    // C:\\work\\simsharp\\Src\\Ssc\\SimSharpGen.g:99:4: valueAssignment
                    {
                    	PushFollow(FOLLOW_valueAssignment_in_statement161);
                    	valueAssignment();
                    	state.followingStackPointer--;
                    	if (state.failed) return ;

                    }
                    break;
                case 4 :
                    // C:\\work\\simsharp\\Src\\Ssc\\SimSharpGen.g:100:4: refAssignment[false]
                    {
                    	PushFollow(FOLLOW_refAssignment_in_statement166);
                    	refAssignment(false);
                    	state.followingStackPointer--;
                    	if (state.failed) return ;

                    }
                    break;
                case 5 :
                    // C:\\work\\simsharp\\Src\\Ssc\\SimSharpGen.g:101:4: procStatement
                    {
                    	PushFollow(FOLLOW_procStatement_in_statement172);
                    	procStatement();
                    	state.followingStackPointer--;
                    	if (state.failed) return ;

                    }
                    break;
                case 6 :
                    // C:\\work\\simsharp\\Src\\Ssc\\SimSharpGen.g:102:4: connection
                    {
                    	PushFollow(FOLLOW_connection_in_statement177);
                    	connection();
                    	state.followingStackPointer--;
                    	if (state.failed) return ;

                    }
                    break;
                case 7 :
                    // C:\\work\\simsharp\\Src\\Ssc\\SimSharpGen.g:103:4: compoundStatement
                    {
                    	PushFollow(FOLLOW_compoundStatement_in_statement182);
                    	compoundStatement();
                    	state.followingStackPointer--;
                    	if (state.failed) return ;

                    }
                    break;
                case 8 :
                    // C:\\work\\simsharp\\Src\\Ssc\\SimSharpGen.g:104:4: condition
                    {
                    	PushFollow(FOLLOW_condition_in_statement187);
                    	condition();
                    	state.followingStackPointer--;
                    	if (state.failed) return ;

                    }
                    break;
                case 9 :
                    // C:\\work\\simsharp\\Src\\Ssc\\SimSharpGen.g:105:4: whileStatement
                    {
                    	PushFollow(FOLLOW_whileStatement_in_statement192);
                    	whileStatement();
                    	state.followingStackPointer--;
                    	if (state.failed) return ;

                    }
                    break;
                case 10 :
                    // C:\\work\\simsharp\\Src\\Ssc\\SimSharpGen.g:106:4: forStatement
                    {
                    	PushFollow(FOLLOW_forStatement_in_statement197);
                    	forStatement();
                    	state.followingStackPointer--;
                    	if (state.failed) return ;

                    }
                    break;
                case 11 :
                    // C:\\work\\simsharp\\Src\\Ssc\\SimSharpGen.g:107:4: objectGenStatement
                    {
                    	PushFollow(FOLLOW_objectGenStatement_in_statement202);
                    	objectGenStatement();
                    	state.followingStackPointer--;
                    	if (state.failed) return ;

                    }
                    break;
                case 12 :
                    // C:\\work\\simsharp\\Src\\Ssc\\SimSharpGen.g:108:4: gotoStatement
                    {
                    	PushFollow(FOLLOW_gotoStatement_in_statement207);
                    	gotoStatement();
                    	state.followingStackPointer--;
                    	if (state.failed) return ;

                    }
                    break;
                case 13 :
                    // C:\\work\\simsharp\\Src\\Ssc\\SimSharpGen.g:109:4: labelStatement
                    {
                    	PushFollow(FOLLOW_labelStatement_in_statement212);
                    	labelStatement();
                    	state.followingStackPointer--;
                    	if (state.failed) return ;

                    }
                    break;

            }
        }
        catch (RecognitionException re) 
    	{
            ReportError(re);
            Recover(input,re);
        }
        finally 
    	{
        }
        return ;
    }
    // $ANTLR end "statement"


    // $ANTLR start "labelStatement"
    // C:\\work\\simsharp\\Src\\Ssc\\SimSharpGen.g:112:1: labelStatement : ^( Label i= ID ) ;
    public void labelStatement() // throws RecognitionException [1]
    {   
        SimSharpTreeNode i = null;

        try 
    	{
            // C:\\work\\simsharp\\Src\\Ssc\\SimSharpGen.g:113:2: ( ^( Label i= ID ) )
            // C:\\work\\simsharp\\Src\\Ssc\\SimSharpGen.g:113:4: ^( Label i= ID )
            {
            	Match(input,Label,FOLLOW_Label_in_labelStatement225); if (state.failed) return ;

            	Match(input, Token.DOWN, null); if (state.failed) return ;
            	i=(SimSharpTreeNode)Match(input,ID,FOLLOW_ID_in_labelStatement229); if (state.failed) return ;

            	Match(input, Token.UP, null); if (state.failed) return ;
            	if ( (state.backtracking==0) )
            	{

            	  		LabelSymbol labSym = i.Symbol as LabelSymbol;
            	  		
            	  		cg.DefineLabel(labSym);
            	  		cg.SetJumpPoint(labSym);
            	  		
            	}

            }

        }
        catch (RecognitionException re) 
    	{
            ReportError(re);
            Recover(input,re);
        }
        finally 
    	{
        }
        return ;
    }
    // $ANTLR end "labelStatement"


    // $ANTLR start "gotoStatement"
    // C:\\work\\simsharp\\Src\\Ssc\\SimSharpGen.g:122:1: gotoStatement : ^( GoTo designationalExpression ) ;
    public void gotoStatement() // throws RecognitionException [1]
    {   
        try 
    	{
            // C:\\work\\simsharp\\Src\\Ssc\\SimSharpGen.g:123:2: ( ^( GoTo designationalExpression ) )
            // C:\\work\\simsharp\\Src\\Ssc\\SimSharpGen.g:123:5: ^( GoTo designationalExpression )
            {
            	Match(input,GoTo,FOLLOW_GoTo_in_gotoStatement248); if (state.failed) return ;

            	Match(input, Token.DOWN, null); if (state.failed) return ;
            	PushFollow(FOLLOW_designationalExpression_in_gotoStatement250);
            	designationalExpression();
            	state.followingStackPointer--;
            	if (state.failed) return ;

            	Match(input, Token.UP, null); if (state.failed) return ;

            }

        }
        catch (RecognitionException re) 
    	{
            ReportError(re);
            Recover(input,re);
        }
        finally 
    	{
        }
        return ;
    }
    // $ANTLR end "gotoStatement"


    // $ANTLR start "designationalExpression"
    // C:\\work\\simsharp\\Src\\Ssc\\SimSharpGen.g:126:1: designationalExpression : ( ^( SwitchDesignator i= ID expression ) | ^( LabelDesignator i= ID ) );
    public void designationalExpression() // throws RecognitionException [1]
    {   
        SimSharpTreeNode i = null;

        try 
    	{
            // C:\\work\\simsharp\\Src\\Ssc\\SimSharpGen.g:127:2: ( ^( SwitchDesignator i= ID expression ) | ^( LabelDesignator i= ID ) )
            int alt3 = 2;
            int LA3_0 = input.LA(1);

            if ( (LA3_0 == SwitchDesignator) )
            {
                alt3 = 1;
            }
            else if ( (LA3_0 == LabelDesignator) )
            {
                alt3 = 2;
            }
            else 
            {
                if ( state.backtracking > 0 ) {state.failed = true; return ;}
                NoViableAltException nvae_d3s0 =
                    new NoViableAltException("", 3, 0, input);

                throw nvae_d3s0;
            }
            switch (alt3) 
            {
                case 1 :
                    // C:\\work\\simsharp\\Src\\Ssc\\SimSharpGen.g:127:4: ^( SwitchDesignator i= ID expression )
                    {
                    	Match(input,SwitchDesignator,FOLLOW_SwitchDesignator_in_designationalExpression264); if (state.failed) return ;

                    	Match(input, Token.DOWN, null); if (state.failed) return ;
                    	i=(SimSharpTreeNode)Match(input,ID,FOLLOW_ID_in_designationalExpression271); if (state.failed) return ;
                    	PushFollow(FOLLOW_expression_in_designationalExpression276);
                    	expression();
                    	state.followingStackPointer--;
                    	if (state.failed) return ;
                    	if ( (state.backtracking==0) )
                    	{

                    	  		SwitchSymbol sw = ctx.Scope.ResolveSwitch(((i != null) ? i.Text : null));
                    	  		cg.Sub1Imediate();	//we need to subtract one since Simula assumes SwitchList starts at 1, .Net switch starts at 0.
                    	  		cg.JumpTable(sw.JumpTable);
                    	  		
                    	}

                    	Match(input, Token.UP, null); if (state.failed) return ;

                    }
                    break;
                case 2 :
                    // C:\\work\\simsharp\\Src\\Ssc\\SimSharpGen.g:136:4: ^( LabelDesignator i= ID )
                    {
                    	Match(input,LabelDesignator,FOLLOW_LabelDesignator_in_designationalExpression293); if (state.failed) return ;

                    	Match(input, Token.DOWN, null); if (state.failed) return ;
                    	i=(SimSharpTreeNode)Match(input,ID,FOLLOW_ID_in_designationalExpression299); if (state.failed) return ;
                    	if ( (state.backtracking==0) )
                    	{

                    	  		  LabelSymbol lab = ctx.Scope.ResolveLabel(((i != null) ? i.Text : null));
                    	  		  cg.DefineLabel(lab);
                    	  		  cg.GotoJumpPoint(lab);
                    	  		
                    	}

                    	Match(input, Token.UP, null); if (state.failed) return ;

                    }
                    break;

            }
        }
        catch (RecognitionException re) 
    	{
            ReportError(re);
            Recover(input,re);
        }
        finally 
    	{
        }
        return ;
    }
    // $ANTLR end "designationalExpression"


    // $ANTLR start "objectGenStatement"
    // C:\\work\\simsharp\\Src\\Ssc\\SimSharpGen.g:146:1: objectGenStatement : objectGenerator ;
    public void objectGenStatement() // throws RecognitionException [1]
    {   
        try 
    	{
            // C:\\work\\simsharp\\Src\\Ssc\\SimSharpGen.g:147:2: ( objectGenerator )
            // C:\\work\\simsharp\\Src\\Ssc\\SimSharpGen.g:147:4: objectGenerator
            {
            	PushFollow(FOLLOW_objectGenerator_in_objectGenStatement321);
            	objectGenerator();
            	state.followingStackPointer--;
            	if (state.failed) return ;
            	if ( (state.backtracking==0) )
            	{
            	   cg.Pop(); 
            	}

            }

        }
        catch (RecognitionException re) 
    	{
            ReportError(re);
            Recover(input,re);
        }
        finally 
    	{
        }
        return ;
    }
    // $ANTLR end "objectGenStatement"


    // $ANTLR start "forStatement"
    // C:\\work\\simsharp\\Src\\Ssc\\SimSharpGen.g:151:1: forStatement : ^( FOR i= ID forRightPart[s, doBody, elemVar] statement ) ;
    public void forStatement() // throws RecognitionException [1]
    {   
        SimSharpTreeNode i = null;
        List<Label> forRightPart2 = default(List<Label>);



        Symbol s = null;
        LabelSymbol doBody = null;;
        Symbol elemVar = null;
        LabelSymbol endFor = null;

        try 
    	{
            // C:\\work\\simsharp\\Src\\Ssc\\SimSharpGen.g:158:2: ( ^( FOR i= ID forRightPart[s, doBody, elemVar] statement ) )
            // C:\\work\\simsharp\\Src\\Ssc\\SimSharpGen.g:158:4: ^( FOR i= ID forRightPart[s, doBody, elemVar] statement )
            {
            	Match(input,FOR,FOLLOW_FOR_in_forStatement343); if (state.failed) return ;

            	Match(input, Token.DOWN, null); if (state.failed) return ;
            	i=(SimSharpTreeNode)Match(input,ID,FOLLOW_ID_in_forStatement350); if (state.failed) return ;
            	if ( (state.backtracking==0) )
            	{

            	  		s = ctx.Scope.Resolve(((i != null) ? i.Text : null));  //.ResolveVariable(((i != null) ? i.Text : null));
            	  		if (s == null) 
            	  		  errMan.ReportError("CodeGen", i.Line, i.CharPositionInLine, "Unrecognized for loop identifier '" + i.Text + "'");
            	  		  
            	  		doBody = cg.DefineJumpPoint();
            	  		elemVar = cg.CreateTempVar("_elemVar", SymbolTable.Integer);
            	  		//cg.Load(scope, new LitteralSymbol(LitteralSymbol.Kind.INT, "0"));
            	  		//cg.ValAssign(scope, elemVar, elemVar.Type);
            	  		
            	}
            	PushFollow(FOLLOW_forRightPart_in_forStatement359);
            	forRightPart2 = forRightPart(s, doBody, elemVar);
            	state.followingStackPointer--;
            	if (state.failed) return ;
            	if ( (state.backtracking==0) )
            	{

            	  		endFor = cg.GotoJumpPoint();
            	  		cg.SetJumpPoint(doBody);
            	  		
            	}
            	PushFollow(FOLLOW_statement_in_forStatement368);
            	statement();
            	state.followingStackPointer--;
            	if (state.failed) return ;
            	if ( (state.backtracking==0) )
            	{

            	  		int count = forRightPart2.Count;
            	  		Label[] jumpTable = new Label[count];
            	  		forRightPart2.CopyTo(jumpTable);

            	  		cg.Load(elemVar);
            	  		cg.JumpTable(jumpTable ); 
            	  		cg.SetJumpPoint(endFor);
            	  		
            	}

            	Match(input, Token.UP, null); if (state.failed) return ;

            }

        }
        catch (RecognitionException re) 
    	{
            ReportError(re);
            Recover(input,re);
        }
        finally 
    	{
        }
        return ;
    }
    // $ANTLR end "forStatement"


    // $ANTLR start "forRightPart"
    // C:\\work\\simsharp\\Src\\Ssc\\SimSharpGen.g:189:1: forRightPart[Symbol controlledVar, LabelSymbol doBody, Symbol elemVar] returns [List<Label> jumpList] : ( ^( VALASSIGN ( forListElement[controlledVar, doBody] )* ) | ^( REFASSIGN (element= refForListElement[controlledVar, doBody] )* ) );
    public List<Label> forRightPart(Symbol controlledVar, LabelSymbol doBody, Symbol elemVar) // throws RecognitionException [1]
    {   
        List<Label> jumpList = default(List<Label>);

        LabelSymbol element = default(LabelSymbol);

        LabelSymbol forListElement3 = default(LabelSymbol);



        bool firstTime = true;

        try 
    	{
            // C:\\work\\simsharp\\Src\\Ssc\\SimSharpGen.g:193:2: ( ^( VALASSIGN ( forListElement[controlledVar, doBody] )* ) | ^( REFASSIGN (element= refForListElement[controlledVar, doBody] )* ) )
            int alt6 = 2;
            int LA6_0 = input.LA(1);

            if ( (LA6_0 == VALASSIGN) )
            {
                alt6 = 1;
            }
            else if ( (LA6_0 == REFASSIGN) )
            {
                alt6 = 2;
            }
            else 
            {
                if ( state.backtracking > 0 ) {state.failed = true; return jumpList;}
                NoViableAltException nvae_d6s0 =
                    new NoViableAltException("", 6, 0, input);

                throw nvae_d6s0;
            }
            switch (alt6) 
            {
                case 1 :
                    // C:\\work\\simsharp\\Src\\Ssc\\SimSharpGen.g:193:4: ^( VALASSIGN ( forListElement[controlledVar, doBody] )* )
                    {
                    	Match(input,VALASSIGN,FOLLOW_VALASSIGN_in_forRightPart404); if (state.failed) return jumpList;

                    	if ( (state.backtracking==0) )
                    	{

                    	  		jumpList = new List<Label>();
                    	  		
                    	}

                    	if ( input.LA(1) == Token.DOWN )
                    	{
                    	    Match(input, Token.DOWN, null); if (state.failed) return jumpList;
                    	    // C:\\work\\simsharp\\Src\\Ssc\\SimSharpGen.g:197:3: ( forListElement[controlledVar, doBody] )*
                    	    do 
                    	    {
                    	        int alt4 = 2;
                    	        int LA4_0 = input.LA(1);

                    	        if ( ((LA4_0 >= StepListElement && LA4_0 <= WhileListElement)) )
                    	        {
                    	            alt4 = 1;
                    	        }


                    	        switch (alt4) 
                    	    	{
                    	    		case 1 :
                    	    		    // C:\\work\\simsharp\\Src\\Ssc\\SimSharpGen.g:198:3: forListElement[controlledVar, doBody]
                    	    		    {
                    	    		    	if ( (state.backtracking==0) )
                    	    		    	{

                    	    		    	  		if (firstTime)
                    	    		    	  		{
                    	    		    	  		  cg.Load(new LitteralSymbol(LitteralSymbol.Kind.INT, "0"));
                    	    		    	  		  cg.ValAssign(elemVar, elemVar.Type);
                    	    		    	  		  firstTime = false;
                    	    		    	  		}
                    	    		    	  		else cg.IncSymbol(elemVar);
                    	    		    	  		
                    	    		    	}
                    	    		    	PushFollow(FOLLOW_forListElement_in_forRightPart421);
                    	    		    	forListElement3 = forListElement(controlledVar, doBody);
                    	    		    	state.followingStackPointer--;
                    	    		    	if (state.failed) return jumpList;
                    	    		    	if ( (state.backtracking==0) )
                    	    		    	{

                    	    		    	  		//cg.IncSymbol(scope, elemVar);		
                    	    		    	  		jumpList.Add(forListElement3.Label);
                    	    		    	  		
                    	    		    	}

                    	    		    }
                    	    		    break;

                    	    		default:
                    	    		    goto loop4;
                    	        }
                    	    } while (true);

                    	    loop4:
                    	    	;	// Stops C# compiler whining that label 'loop4' has no statements


                    	    Match(input, Token.UP, null); if (state.failed) return jumpList;
                    	}

                    }
                    break;
                case 2 :
                    // C:\\work\\simsharp\\Src\\Ssc\\SimSharpGen.g:214:4: ^( REFASSIGN (element= refForListElement[controlledVar, doBody] )* )
                    {
                    	Match(input,REFASSIGN,FOLLOW_REFASSIGN_in_forRightPart443); if (state.failed) return jumpList;

                    	if ( (state.backtracking==0) )
                    	{

                    	  		jumpList = new List<Label>();
                    	  		cg.Load(new LitteralSymbol(LitteralSymbol.Kind.INT, "0"));
                    	  		cg.ValAssign(elemVar, elemVar.Type);
                    	  		
                    	}

                    	if ( input.LA(1) == Token.DOWN )
                    	{
                    	    Match(input, Token.DOWN, null); if (state.failed) return jumpList;
                    	    // C:\\work\\simsharp\\Src\\Ssc\\SimSharpGen.g:220:3: (element= refForListElement[controlledVar, doBody] )*
                    	    do 
                    	    {
                    	        int alt5 = 2;
                    	        int LA5_0 = input.LA(1);

                    	        if ( (LA5_0 == WhileListElement) )
                    	        {
                    	            alt5 = 1;
                    	        }


                    	        switch (alt5) 
                    	    	{
                    	    		case 1 :
                    	    		    // C:\\work\\simsharp\\Src\\Ssc\\SimSharpGen.g:221:3: element= refForListElement[controlledVar, doBody]
                    	    		    {
                    	    		    	PushFollow(FOLLOW_refForListElement_in_forRightPart457);
                    	    		    	element = refForListElement(controlledVar, doBody);
                    	    		    	state.followingStackPointer--;
                    	    		    	if (state.failed) return jumpList;
                    	    		    	if ( (state.backtracking==0) )
                    	    		    	{

                    	    		    	  		cg.IncSymbol(elemVar);
                    	    		    	  		jumpList.Add(element.Label);
                    	    		    	  		
                    	    		    	}

                    	    		    }
                    	    		    break;

                    	    		default:
                    	    		    goto loop5;
                    	        }
                    	    } while (true);

                    	    loop5:
                    	    	;	// Stops C# compiler whining that label 'loop5' has no statements


                    	    Match(input, Token.UP, null); if (state.failed) return jumpList;
                    	}

                    }
                    break;

            }
        }
        catch (RecognitionException re) 
    	{
            ReportError(re);
            Recover(input,re);
        }
        finally 
    	{
        }
        return jumpList;
    }
    // $ANTLR end "forRightPart"


    // $ANTLR start "forListElement"
    // C:\\work\\simsharp\\Src\\Ssc\\SimSharpGen.g:231:1: forListElement[Symbol controlledVar, LabelSymbol doBody] returns [LabelSymbol nextStep] : ( ^( StepListElement first= expression STEP dir= expression step= expression UNTIL expression ) | ^( WhileListElement e= expression ) );
    public LabelSymbol forListElement(Symbol controlledVar, LabelSymbol doBody) // throws RecognitionException [1]
    {   
        LabelSymbol nextStep = default(LabelSymbol);

        SimSharpGen.expression_return first = default(SimSharpGen.expression_return);

        SimSharpGen.expression_return dir = default(SimSharpGen.expression_return);

        SimSharpGen.expression_return step = default(SimSharpGen.expression_return);

        SimSharpGen.expression_return e = default(SimSharpGen.expression_return);



        VariableSymbol direction = null;

        try 
    	{
            // C:\\work\\simsharp\\Src\\Ssc\\SimSharpGen.g:235:2: ( ^( StepListElement first= expression STEP dir= expression step= expression UNTIL expression ) | ^( WhileListElement e= expression ) )
            int alt7 = 2;
            int LA7_0 = input.LA(1);

            if ( (LA7_0 == StepListElement) )
            {
                alt7 = 1;
            }
            else if ( (LA7_0 == WhileListElement) )
            {
                alt7 = 2;
            }
            else 
            {
                if ( state.backtracking > 0 ) {state.failed = true; return nextStep;}
                NoViableAltException nvae_d7s0 =
                    new NoViableAltException("", 7, 0, input);

                throw nvae_d7s0;
            }
            switch (alt7) 
            {
                case 1 :
                    // C:\\work\\simsharp\\Src\\Ssc\\SimSharpGen.g:235:4: ^( StepListElement first= expression STEP dir= expression step= expression UNTIL expression )
                    {
                    	Match(input,StepListElement,FOLLOW_StepListElement_in_forListElement497); if (state.failed) return nextStep;

                    	if ( (state.backtracking==0) )
                    	{

                    	  		cg.LoadThisOrInspect(controlledVar);
                    	  		
                    	}

                    	Match(input, Token.DOWN, null); if (state.failed) return nextStep;
                    	PushFollow(FOLLOW_expression_in_forListElement508);
                    	first = expression();
                    	state.followingStackPointer--;
                    	if (state.failed) return nextStep;
                    	if ( (state.backtracking==0) )
                    	{

                    	  		cg.ValAssign(controlledVar, ((first != null) ? first.t : default(TypeSymbol)));
                    	  		
                    	}
                    	Match(input,STEP,FOLLOW_STEP_in_forListElement517); if (state.failed) return nextStep;
                    	PushFollow(FOLLOW_expression_in_forListElement527);
                    	dir = expression();
                    	state.followingStackPointer--;
                    	if (state.failed) return nextStep;
                    	if ( (state.backtracking==0) )
                    	{

                    	  		direction = cg.CreateTempVar("_dir", SymbolTable.Integer);
                    	  		cg.Load(new LitteralSymbol(LitteralSymbol.Kind.INT, "0"));
                    	  		cg.ExprLt();
                    	  		cg.ValAssign(direction, SymbolTable.Integer);
                    	  		
                    	  		cg.GotoJumpPoint(doBody);
                    	  		
                    	  		//We come back here for next step
                    	  		nextStep = cg.CreateAndSetJumpPoint();
                    	  		
                    	  		cg.LoadThisOrInspect(controlledVar);
                    	  		
                    	}
                    	PushFollow(FOLLOW_expression_in_forListElement537);
                    	step = expression();
                    	state.followingStackPointer--;
                    	if (state.failed) return nextStep;
                    	if ( (state.backtracking==0) )
                    	{

                    	  		cg.LoadThisOrInspect(controlledVar);
                    	  		cg.Load(controlledVar);
                    	  		
                    	  		cg.ExprPlus();
                    	  		
                    	  		cg.ValAssign(controlledVar, ((step != null) ? step.t : default(TypeSymbol)));
                    	  		
                    	  		cg.LoadThisOrInspect(controlledVar);
                    	  		cg.Load(controlledVar);
                    	  		
                    	}
                    	Match(input,UNTIL,FOLLOW_UNTIL_in_forListElement546); if (state.failed) return nextStep;
                    	PushFollow(FOLLOW_expression_in_forListElement551);
                    	expression();
                    	state.followingStackPointer--;
                    	if (state.failed) return nextStep;
                    	if ( (state.backtracking==0) )
                    	{

                    	  		
                    	  		cg.Load(direction);
                    	  		LabelSymbol posDir = cg.BranchIfFalse();  //positive direction
                    	  		
                    	  		cg.ExprLt();
                    	  		cg.BranchIfFalse(doBody);
                    	  		LabelSymbol exit = cg.GotoJumpPoint();
                    	  		
                    	  		cg.SetJumpPoint(posDir);
                    	  		cg.ExprGt();
                    	  		cg.BranchIfFalse(doBody);
                    	  		
                    	  		cg.SetJumpPoint(exit);
                    	  		
                    	}

                    	Match(input, Token.UP, null); if (state.failed) return nextStep;

                    }
                    break;
                case 2 :
                    // C:\\work\\simsharp\\Src\\Ssc\\SimSharpGen.g:289:4: ^( WhileListElement e= expression )
                    {
                    	Match(input,WhileListElement,FOLLOW_WhileListElement_in_forListElement567); if (state.failed) return nextStep;

                    	if ( (state.backtracking==0) )
                    	{

                    	  		cg.LoadThisOrInspect(controlledVar);
                    	  		
                    	}

                    	Match(input, Token.DOWN, null); if (state.failed) return nextStep;
                    	PushFollow(FOLLOW_expression_in_forListElement578);
                    	e = expression();
                    	state.followingStackPointer--;
                    	if (state.failed) return nextStep;
                    	if ( (state.backtracking==0) )
                    	{

                    	  		cg.ValAssign(controlledVar, ((e != null) ? e.t : default(TypeSymbol)));
                    	  		
                    	  		cg.GotoJumpPoint(doBody);

                    	  		//We come back here for next step
                    	  		nextStep = cg.CreateAndSetJumpPoint();
                    	  		
                    	}

                    	Match(input, Token.UP, null); if (state.failed) return nextStep;

                    }
                    break;

            }
        }
        catch (RecognitionException re) 
    	{
            ReportError(re);
            Recover(input,re);
        }
        finally 
    	{
        }
        return nextStep;
    }
    // $ANTLR end "forListElement"


    // $ANTLR start "refForListElement"
    // C:\\work\\simsharp\\Src\\Ssc\\SimSharpGen.g:306:1: refForListElement[Symbol controlledVar, LabelSymbol doBody] returns [LabelSymbol nextStep] : ^( WhileListElement e= expression ) ;
    public LabelSymbol refForListElement(Symbol controlledVar, LabelSymbol doBody) // throws RecognitionException [1]
    {   
        LabelSymbol nextStep = default(LabelSymbol);

        SimSharpGen.expression_return e = default(SimSharpGen.expression_return);


        try 
    	{
            // C:\\work\\simsharp\\Src\\Ssc\\SimSharpGen.g:307:2: ( ^( WhileListElement e= expression ) )
            // C:\\work\\simsharp\\Src\\Ssc\\SimSharpGen.g:307:4: ^( WhileListElement e= expression )
            {
            	Match(input,WhileListElement,FOLLOW_WhileListElement_in_refForListElement609); if (state.failed) return nextStep;

            	if ( (state.backtracking==0) )
            	{

            	  		cg.LoadThisOrInspect(controlledVar);
            	  		
            	}

            	Match(input, Token.DOWN, null); if (state.failed) return nextStep;
            	PushFollow(FOLLOW_expression_in_refForListElement620);
            	e = expression();
            	state.followingStackPointer--;
            	if (state.failed) return nextStep;
            	if ( (state.backtracking==0) )
            	{

            	  		cg.RefAssign(controlledVar, ((e != null) ? e.t : default(TypeSymbol)));
            	  		
            	  		cg.GotoJumpPoint(doBody);

            	  		//We come back here for next step
            	  		nextStep = cg.CreateAndSetJumpPoint();
            	  		
            	}

            	Match(input, Token.UP, null); if (state.failed) return nextStep;

            }

        }
        catch (RecognitionException re) 
    	{
            ReportError(re);
            Recover(input,re);
        }
        finally 
    	{
        }
        return nextStep;
    }
    // $ANTLR end "refForListElement"


    // $ANTLR start "whileStatement"
    // C:\\work\\simsharp\\Src\\Ssc\\SimSharpGen.g:324:1: whileStatement : ^( WHILE expression statement ) ;
    public void whileStatement() // throws RecognitionException [1]
    {   

        LabelSymbol loopLabel = null, endLabel = null;

        try 
    	{
            // C:\\work\\simsharp\\Src\\Ssc\\SimSharpGen.g:328:2: ( ^( WHILE expression statement ) )
            // C:\\work\\simsharp\\Src\\Ssc\\SimSharpGen.g:328:4: ^( WHILE expression statement )
            {
            	Match(input,WHILE,FOLLOW_WHILE_in_whileStatement652); if (state.failed) return ;

            	if ( (state.backtracking==0) )
            	{
            	   loopLabel = cg.CreateAndSetJumpPoint(); 
            	}

            	Match(input, Token.DOWN, null); if (state.failed) return ;
            	PushFollow(FOLLOW_expression_in_whileStatement667);
            	expression();
            	state.followingStackPointer--;
            	if (state.failed) return ;
            	if ( (state.backtracking==0) )
            	{

            	  		endLabel = cg.BranchIfFalse();
            	  		
            	}
            	PushFollow(FOLLOW_statement_in_whileStatement676);
            	statement();
            	state.followingStackPointer--;
            	if (state.failed) return ;
            	if ( (state.backtracking==0) )
            	{
            	   
            	  		cg.GotoJumpPoint(loopLabel); 
            	  		cg.SetJumpPoint(endLabel);
            	  		
            	}

            	Match(input, Token.UP, null); if (state.failed) return ;

            }

        }
        catch (RecognitionException re) 
    	{
            ReportError(re);
            Recover(input,re);
        }
        finally 
    	{
        }
        return ;
    }
    // $ANTLR end "whileStatement"


    // $ANTLR start "condition"
    // C:\\work\\simsharp\\Src\\Ssc\\SimSharpGen.g:343:1: condition : ^( IF expression statement ( statement )? ) ;
    public void condition() // throws RecognitionException [1]
    {   

        LabelSymbol endLabel = null;

        try 
    	{
            // C:\\work\\simsharp\\Src\\Ssc\\SimSharpGen.g:347:2: ( ^( IF expression statement ( statement )? ) )
            // C:\\work\\simsharp\\Src\\Ssc\\SimSharpGen.g:347:5: ^( IF expression statement ( statement )? )
            {
            	Match(input,IF,FOLLOW_IF_in_condition708); if (state.failed) return ;

            	Match(input, Token.DOWN, null); if (state.failed) return ;
            	PushFollow(FOLLOW_expression_in_condition713);
            	expression();
            	state.followingStackPointer--;
            	if (state.failed) return ;
            	if ( (state.backtracking==0) )
            	{
            	   endLabel = cg.BranchIfFalse(); 
            	}
            	PushFollow(FOLLOW_statement_in_condition722);
            	statement();
            	state.followingStackPointer--;
            	if (state.failed) return ;
            	// C:\\work\\simsharp\\Src\\Ssc\\SimSharpGen.g:352:3: ( statement )?
            	int alt8 = 2;
            	int LA8_0 = input.LA(1);

            	if ( (LA8_0 == Block || LA8_0 == CompoundStatement || LA8_0 == MethCall || (LA8_0 >= Label && LA8_0 <= GoTo) || LA8_0 == PrefixedBlock || (LA8_0 >= VALASSIGN && LA8_0 <= REFASSIGN) || LA8_0 == IF || LA8_0 == WHILE || LA8_0 == FOR || LA8_0 == INSPECT || LA8_0 == NEW) )
            	{
            	    alt8 = 1;
            	}
            	switch (alt8) 
            	{
            	    case 1 :
            	        // C:\\work\\simsharp\\Src\\Ssc\\SimSharpGen.g:353:3: statement
            	        {
            	        	if ( (state.backtracking==0) )
            	        	{

            	        	  		LabelSymbol elseLabel = endLabel;
            	        	  		endLabel = cg.GotoJumpPoint(); 
            	        	  	  	cg.SetJumpPoint(elseLabel); 
            	        	  		
            	        	}
            	        	PushFollow(FOLLOW_statement_in_condition739);
            	        	statement();
            	        	state.followingStackPointer--;
            	        	if (state.failed) return ;

            	        }
            	        break;

            	}

            	if ( (state.backtracking==0) )
            	{
            	   cg.SetJumpPoint(endLabel); 
            	}

            	Match(input, Token.UP, null); if (state.failed) return ;

            }

        }
        catch (RecognitionException re) 
    	{
            ReportError(re);
            Recover(input,re);
        }
        finally 
    	{
        }
        return ;
    }
    // $ANTLR end "condition"


    // $ANTLR start "compoundStatement"
    // C:\\work\\simsharp\\Src\\Ssc\\SimSharpGen.g:364:1: compoundStatement : ^( CompoundStatement ( statement )* ) ;
    public void compoundStatement() // throws RecognitionException [1]
    {   
        try 
    	{
            // C:\\work\\simsharp\\Src\\Ssc\\SimSharpGen.g:365:2: ( ^( CompoundStatement ( statement )* ) )
            // C:\\work\\simsharp\\Src\\Ssc\\SimSharpGen.g:365:4: ^( CompoundStatement ( statement )* )
            {
            	Match(input,CompoundStatement,FOLLOW_CompoundStatement_in_compoundStatement767); if (state.failed) return ;

            	if ( input.LA(1) == Token.DOWN )
            	{
            	    Match(input, Token.DOWN, null); if (state.failed) return ;
            	    // C:\\work\\simsharp\\Src\\Ssc\\SimSharpGen.g:366:6: ( statement )*
            	    do 
            	    {
            	        int alt9 = 2;
            	        int LA9_0 = input.LA(1);

            	        if ( (LA9_0 == Block || LA9_0 == CompoundStatement || LA9_0 == MethCall || (LA9_0 >= Label && LA9_0 <= GoTo) || LA9_0 == PrefixedBlock || (LA9_0 >= VALASSIGN && LA9_0 <= REFASSIGN) || LA9_0 == IF || LA9_0 == WHILE || LA9_0 == FOR || LA9_0 == INSPECT || LA9_0 == NEW) )
            	        {
            	            alt9 = 1;
            	        }


            	        switch (alt9) 
            	    	{
            	    		case 1 :
            	    		    // C:\\work\\simsharp\\Src\\Ssc\\SimSharpGen.g:366:6: statement
            	    		    {
            	    		    	PushFollow(FOLLOW_statement_in_compoundStatement775);
            	    		    	statement();
            	    		    	state.followingStackPointer--;
            	    		    	if (state.failed) return ;

            	    		    }
            	    		    break;

            	    		default:
            	    		    goto loop9;
            	        }
            	    } while (true);

            	    loop9:
            	    	;	// Stops C# compiler whining that label 'loop9' has no statements


            	    Match(input, Token.UP, null); if (state.failed) return ;
            	}

            }

        }
        catch (RecognitionException re) 
    	{
            ReportError(re);
            Recover(input,re);
        }
        finally 
    	{
        }
        return ;
    }
    // $ANTLR end "compoundStatement"


    // $ANTLR start "connection"
    // C:\\work\\simsharp\\Src\\Ssc\\SimSharpGen.g:369:1: connection : ^( INSPECT e= expression ( connect2 | ( whenClause[exprVar, end] )+ ) ( otherwiseClause )? ) ;
    public void connection() // throws RecognitionException [1]
    {   
        SimSharpGen.expression_return e = default(SimSharpGen.expression_return);



        LabelSymbol otherwise = null, end = null;
        VariableSymbol exprVar = null;

        try 
    	{
            // C:\\work\\simsharp\\Src\\Ssc\\SimSharpGen.g:374:2: ( ^( INSPECT e= expression ( connect2 | ( whenClause[exprVar, end] )+ ) ( otherwiseClause )? ) )
            // C:\\work\\simsharp\\Src\\Ssc\\SimSharpGen.g:374:4: ^( INSPECT e= expression ( connect2 | ( whenClause[exprVar, end] )+ ) ( otherwiseClause )? )
            {
            	Match(input,INSPECT,FOLLOW_INSPECT_in_connection795); if (state.failed) return ;

            	Match(input, Token.DOWN, null); if (state.failed) return ;
            	PushFollow(FOLLOW_expression_in_connection802);
            	e = expression();
            	state.followingStackPointer--;
            	if (state.failed) return ;
            	// C:\\work\\simsharp\\Src\\Ssc\\SimSharpGen.g:377:3: ( connect2 | ( whenClause[exprVar, end] )+ )
            	int alt11 = 2;
            	int LA11_0 = input.LA(1);

            	if ( (LA11_0 == ConnectBlock2) )
            	{
            	    alt11 = 1;
            	}
            	else if ( (LA11_0 == WHEN) )
            	{
            	    alt11 = 2;
            	}
            	else 
            	{
            	    if ( state.backtracking > 0 ) {state.failed = true; return ;}
            	    NoViableAltException nvae_d11s0 =
            	        new NoViableAltException("", 11, 0, input);

            	    throw nvae_d11s0;
            	}
            	switch (alt11) 
            	{
            	    case 1 :
            	        // C:\\work\\simsharp\\Src\\Ssc\\SimSharpGen.g:378:4: connect2
            	        {
            	        	if ( (state.backtracking==0) )
            	        	{

            	        	  			TypeSymbol inspectType = ((e != null) ? e.t : default(TypeSymbol));
            	        	  			InspectSymbol inspectScope = cg.Connect(inspectType);
            	        	  	
            	        	  		  	otherwise = cg.BranchIfNull(inspectScope.InspectedSymbol); 
            	        	  	
            	        	  		  	ctx.Push(inspectScope);
            	        	  				//TODO: consider to use a Block inside the connection statement to hold local variables.		  
            	        	  			
            	        	}
            	        	PushFollow(FOLLOW_connect2_in_connection818);
            	        	connect2();
            	        	state.followingStackPointer--;
            	        	if (state.failed) return ;
            	        	if ( (state.backtracking==0) )
            	        	{

            	        	  			ctx.Pop();
            	        	  			end = cg.GotoJumpPoint();
            	        	  			
            	        	}

            	        }
            	        break;
            	    case 2 :
            	        // C:\\work\\simsharp\\Src\\Ssc\\SimSharpGen.g:393:4: ( whenClause[exprVar, end] )+
            	        {
            	        	if ( (state.backtracking==0) )
            	        	{

            	        	  			  exprVar = cg.CreateTempVar("_connect", ((e != null) ? e.t : default(TypeSymbol)));
            	        	  			  cg.RefAssign(exprVar, ((e != null) ? e.t : default(TypeSymbol)));
            	        	  			  otherwise = cg.BranchIfNull(exprVar);
            	        	  			  end = cg.DefineJumpPoint();
            	        	  			
            	        	}
            	        	// C:\\work\\simsharp\\Src\\Ssc\\SimSharpGen.g:399:4: ( whenClause[exprVar, end] )+
            	        	int cnt10 = 0;
            	        	do 
            	        	{
            	        	    int alt10 = 2;
            	        	    int LA10_0 = input.LA(1);

            	        	    if ( (LA10_0 == WHEN) )
            	        	    {
            	        	        alt10 = 1;
            	        	    }


            	        	    switch (alt10) 
            	        		{
            	        			case 1 :
            	        			    // C:\\work\\simsharp\\Src\\Ssc\\SimSharpGen.g:400:5: whenClause[exprVar, end]
            	        			    {
            	        			    	PushFollow(FOLLOW_whenClause_in_connection844);
            	        			    	whenClause(exprVar, end);
            	        			    	state.followingStackPointer--;
            	        			    	if (state.failed) return ;

            	        			    }
            	        			    break;

            	        			default:
            	        			    if ( cnt10 >= 1 ) goto loop10;
            	        			    if ( state.backtracking > 0 ) {state.failed = true; return ;}
            	        		            EarlyExitException eee10 =
            	        		                new EarlyExitException(10, input);
            	        		            throw eee10;
            	        	    }
            	        	    cnt10++;
            	        	} while (true);

            	        	loop10:
            	        		;	// Stops C# compiler whinging that label 'loop10' has no statements


            	        }
            	        break;

            	}

            	if ( (state.backtracking==0) )
            	{
            	   cg.SetJumpPoint(otherwise); 
            	}
            	// C:\\work\\simsharp\\Src\\Ssc\\SimSharpGen.g:404:3: ( otherwiseClause )?
            	int alt12 = 2;
            	int LA12_0 = input.LA(1);

            	if ( (LA12_0 == OTHERWISE) )
            	{
            	    alt12 = 1;
            	}
            	switch (alt12) 
            	{
            	    case 1 :
            	        // C:\\work\\simsharp\\Src\\Ssc\\SimSharpGen.g:404:3: otherwiseClause
            	        {
            	        	PushFollow(FOLLOW_otherwiseClause_in_connection863);
            	        	otherwiseClause();
            	        	state.followingStackPointer--;
            	        	if (state.failed) return ;

            	        }
            	        break;

            	}

            	if ( (state.backtracking==0) )
            	{
            	   cg.SetJumpPoint(end); 
            	}

            	Match(input, Token.UP, null); if (state.failed) return ;

            }

        }
        catch (RecognitionException re) 
    	{
            ReportError(re);
            Recover(input,re);
        }
        finally 
    	{
        }
        return ;
    }
    // $ANTLR end "connection"


    // $ANTLR start "whenClause"
    // C:\\work\\simsharp\\Src\\Ssc\\SimSharpGen.g:409:1: whenClause[VariableSymbol exprVar, LabelSymbol end] : ^( WHEN c= classId connect1 ) ;
    public void whenClause(VariableSymbol exprVar, LabelSymbol end) // throws RecognitionException [1]
    {   
        SimSharpGen.classId_return c = default(SimSharpGen.classId_return);



        LabelSymbol next = null;

        try 
    	{
            // C:\\work\\simsharp\\Src\\Ssc\\SimSharpGen.g:413:2: ( ^( WHEN c= classId connect1 ) )
            // C:\\work\\simsharp\\Src\\Ssc\\SimSharpGen.g:413:4: ^( WHEN c= classId connect1 )
            {
            	Match(input,WHEN,FOLLOW_WHEN_in_whenClause893); if (state.failed) return ;

            	Match(input, Token.DOWN, null); if (state.failed) return ;
            	PushFollow(FOLLOW_classId_in_whenClause900);
            	c = classId();
            	state.followingStackPointer--;
            	if (state.failed) return ;
            	if ( (state.backtracking==0) )
            	{

            	  		  cg.Load(exprVar);
            	  		  cg.ExprIn(((c != null) ? c.type : default(TypeSymbol)));
            	  		  next = cg.BranchIfFalse();
            	  		  cg.Load(exprVar);
            	  		  if (!cg.TypeConvert(exprVar.Type, ((c != null) ? c.type : default(TypeSymbol))))
            	  		    errMan.ReportError("CodeGen", ((c != null) ? ((SimSharpTreeNode)c.Start) : null).Line, ((c != null) ? ((SimSharpTreeNode)c.Start) : null).CharPositionInLine, 
            	  		    "Incopatible types in WhenClause. Type '" + exprVar.Type.Name + "' not compatible with '" + (((c != null) ? c.type : default(TypeSymbol))).Name + "'.");
            	  		  InspectSymbol inspect = cg.Connect(((c != null) ? c.type : default(TypeSymbol)));
            	  		  ctx.Push(inspect);
            	  		
            	}
            	PushFollow(FOLLOW_connect1_in_whenClause909);
            	connect1();
            	state.followingStackPointer--;
            	if (state.failed) return ;
            	if ( (state.backtracking==0) )
            	{
            	   
            	  		  ctx.Pop();
            	  		  cg.GotoJumpPoint(end); 
            	  		  cg.SetJumpPoint(next);
            	  		
            	}

            	Match(input, Token.UP, null); if (state.failed) return ;

            }

        }
        catch (RecognitionException re) 
    	{
            ReportError(re);
            Recover(input,re);
        }
        finally 
    	{
        }
        return ;
    }
    // $ANTLR end "whenClause"


    // $ANTLR start "otherwiseClause"
    // C:\\work\\simsharp\\Src\\Ssc\\SimSharpGen.g:435:1: otherwiseClause : ^( OTHERWISE statement ) ;
    public void otherwiseClause() // throws RecognitionException [1]
    {   
        try 
    	{
            // C:\\work\\simsharp\\Src\\Ssc\\SimSharpGen.g:436:2: ( ^( OTHERWISE statement ) )
            // C:\\work\\simsharp\\Src\\Ssc\\SimSharpGen.g:436:4: ^( OTHERWISE statement )
            {
            	Match(input,OTHERWISE,FOLLOW_OTHERWISE_in_otherwiseClause932); if (state.failed) return ;

            	Match(input, Token.DOWN, null); if (state.failed) return ;
            	PushFollow(FOLLOW_statement_in_otherwiseClause934);
            	statement();
            	state.followingStackPointer--;
            	if (state.failed) return ;

            	Match(input, Token.UP, null); if (state.failed) return ;

            }

        }
        catch (RecognitionException re) 
    	{
            ReportError(re);
            Recover(input,re);
        }
        finally 
    	{
        }
        return ;
    }
    // $ANTLR end "otherwiseClause"


    // $ANTLR start "connect1"
    // C:\\work\\simsharp\\Src\\Ssc\\SimSharpGen.g:439:1: connect1 : ^( ConnectBlock1 statement ) ;
    public void connect1() // throws RecognitionException [1]
    {   
        try 
    	{
            // C:\\work\\simsharp\\Src\\Ssc\\SimSharpGen.g:440:2: ( ^( ConnectBlock1 statement ) )
            // C:\\work\\simsharp\\Src\\Ssc\\SimSharpGen.g:440:4: ^( ConnectBlock1 statement )
            {
            	Match(input,ConnectBlock1,FOLLOW_ConnectBlock1_in_connect1948); if (state.failed) return ;

            	Match(input, Token.DOWN, null); if (state.failed) return ;
            	PushFollow(FOLLOW_statement_in_connect1950);
            	statement();
            	state.followingStackPointer--;
            	if (state.failed) return ;

            	Match(input, Token.UP, null); if (state.failed) return ;

            }

        }
        catch (RecognitionException re) 
    	{
            ReportError(re);
            Recover(input,re);
        }
        finally 
    	{
        }
        return ;
    }
    // $ANTLR end "connect1"


    // $ANTLR start "connect2"
    // C:\\work\\simsharp\\Src\\Ssc\\SimSharpGen.g:443:1: connect2 : ^( ConnectBlock2 statement ) ;
    public void connect2() // throws RecognitionException [1]
    {   
        try 
    	{
            // C:\\work\\simsharp\\Src\\Ssc\\SimSharpGen.g:443:9: ( ^( ConnectBlock2 statement ) )
            // C:\\work\\simsharp\\Src\\Ssc\\SimSharpGen.g:443:11: ^( ConnectBlock2 statement )
            {
            	Match(input,ConnectBlock2,FOLLOW_ConnectBlock2_in_connect2962); if (state.failed) return ;

            	Match(input, Token.DOWN, null); if (state.failed) return ;
            	PushFollow(FOLLOW_statement_in_connect2964);
            	statement();
            	state.followingStackPointer--;
            	if (state.failed) return ;

            	Match(input, Token.UP, null); if (state.failed) return ;

            }

        }
        catch (RecognitionException re) 
    	{
            ReportError(re);
            Recover(input,re);
        }
        finally 
    	{
        }
        return ;
    }
    // $ANTLR end "connect2"


    // $ANTLR start "procStatement"
    // C:\\work\\simsharp\\Src\\Ssc\\SimSharpGen.g:446:1: procStatement : methCall ;
    public void procStatement() // throws RecognitionException [1]
    {   
        try 
    	{
            // C:\\work\\simsharp\\Src\\Ssc\\SimSharpGen.g:447:2: ( methCall )
            // C:\\work\\simsharp\\Src\\Ssc\\SimSharpGen.g:447:4: methCall
            {
            	PushFollow(FOLLOW_methCall_in_procStatement977);
            	methCall();
            	state.followingStackPointer--;
            	if (state.failed) return ;
            	if ( (state.backtracking==0) )
            	{


            	  	
            	}

            }

        }
        catch (RecognitionException re) 
    	{
            ReportError(re);
            Recover(input,re);
        }
        finally 
    	{
        }
        return ;
    }
    // $ANTLR end "procStatement"


    // $ANTLR start "methCall"
    // C:\\work\\simsharp\\Src\\Ssc\\SimSharpGen.g:453:1: methCall : ^( MethCall e= expression ) ;
    public void methCall() // throws RecognitionException [1]
    {   
        SimSharpGen.expression_return e = default(SimSharpGen.expression_return);


        try 
    	{
            // C:\\work\\simsharp\\Src\\Ssc\\SimSharpGen.g:453:9: ( ^( MethCall e= expression ) )
            // C:\\work\\simsharp\\Src\\Ssc\\SimSharpGen.g:453:11: ^( MethCall e= expression )
            {
            	Match(input,MethCall,FOLLOW_MethCall_in_methCall991); if (state.failed) return ;

            	Match(input, Token.DOWN, null); if (state.failed) return ;
            	PushFollow(FOLLOW_expression_in_methCall995);
            	e = expression();
            	state.followingStackPointer--;
            	if (state.failed) return ;

            	Match(input, Token.UP, null); if (state.failed) return ;
            	if ( (state.backtracking==0) )
            	{

            	  		if (((e != null) ? e.t : default(TypeSymbol)) != SymbolTable.NoType) cg.Pop();
            	  		
            	}

            }

        }
        catch (RecognitionException re) 
    	{
            ReportError(re);
            Recover(input,re);
        }
        finally 
    	{
        }
        return ;
    }
    // $ANTLR end "methCall"


    // $ANTLR start "block"
    // C:\\work\\simsharp\\Src\\Ssc\\SimSharpGen.g:496:1: block : ^( Block ( declaration )* ( statement )* ) ;
    public void block() // throws RecognitionException [1]
    {   
        try 
    	{
            // C:\\work\\simsharp\\Src\\Ssc\\SimSharpGen.g:496:7: ( ^( Block ( declaration )* ( statement )* ) )
            // C:\\work\\simsharp\\Src\\Ssc\\SimSharpGen.g:497:4: ^( Block ( declaration )* ( statement )* )
            {
            	Match(input,Block,FOLLOW_Block_in_block1020); if (state.failed) return ;

            	if ( input.LA(1) == Token.DOWN )
            	{
            	    Match(input, Token.DOWN, null); if (state.failed) return ;
            	    // C:\\work\\simsharp\\Src\\Ssc\\SimSharpGen.g:498:6: ( declaration )*
            	    do 
            	    {
            	        int alt13 = 2;
            	        int LA13_0 = input.LA(1);

            	        if ( (LA13_0 == VarDecl || LA13_0 == ProcDecl || LA13_0 == ClassDecl || LA13_0 == ArrayDecl || LA13_0 == SWITCH) )
            	        {
            	            alt13 = 1;
            	        }


            	        switch (alt13) 
            	    	{
            	    		case 1 :
            	    		    // C:\\work\\simsharp\\Src\\Ssc\\SimSharpGen.g:498:6: declaration
            	    		    {
            	    		    	PushFollow(FOLLOW_declaration_in_block1028);
            	    		    	declaration();
            	    		    	state.followingStackPointer--;
            	    		    	if (state.failed) return ;

            	    		    }
            	    		    break;

            	    		default:
            	    		    goto loop13;
            	        }
            	    } while (true);

            	    loop13:
            	    	;	// Stops C# compiler whining that label 'loop13' has no statements

            	    // C:\\work\\simsharp\\Src\\Ssc\\SimSharpGen.g:498:19: ( statement )*
            	    do 
            	    {
            	        int alt14 = 2;
            	        int LA14_0 = input.LA(1);

            	        if ( (LA14_0 == Block || LA14_0 == CompoundStatement || LA14_0 == MethCall || (LA14_0 >= Label && LA14_0 <= GoTo) || LA14_0 == PrefixedBlock || (LA14_0 >= VALASSIGN && LA14_0 <= REFASSIGN) || LA14_0 == IF || LA14_0 == WHILE || LA14_0 == FOR || LA14_0 == INSPECT || LA14_0 == NEW) )
            	        {
            	            alt14 = 1;
            	        }


            	        switch (alt14) 
            	    	{
            	    		case 1 :
            	    		    // C:\\work\\simsharp\\Src\\Ssc\\SimSharpGen.g:498:19: statement
            	    		    {
            	    		    	PushFollow(FOLLOW_statement_in_block1031);
            	    		    	statement();
            	    		    	state.followingStackPointer--;
            	    		    	if (state.failed) return ;

            	    		    }
            	    		    break;

            	    		default:
            	    		    goto loop14;
            	        }
            	    } while (true);

            	    loop14:
            	    	;	// Stops C# compiler whining that label 'loop14' has no statements


            	    Match(input, Token.UP, null); if (state.failed) return ;
            	}

            }

        }
        catch (RecognitionException re) 
    	{
            ReportError(re);
            Recover(input,re);
        }
        finally 
    	{
        }
        return ;
    }
    // $ANTLR end "block"


    // $ANTLR start "prefixedBlock"
    // C:\\work\\simsharp\\Src\\Ssc\\SimSharpGen.g:501:1: prefixedBlock : ^(p= PrefixedBlock ID p= ID ( block | compoundStatement ) objectGenStatement ) ;
    public void prefixedBlock() // throws RecognitionException [1]
    {   
        SimSharpTreeNode p = null;


        TypeSymbol c = null;

        try 
    	{
            // C:\\work\\simsharp\\Src\\Ssc\\SimSharpGen.g:505:2: ( ^(p= PrefixedBlock ID p= ID ( block | compoundStatement ) objectGenStatement ) )
            // C:\\work\\simsharp\\Src\\Ssc\\SimSharpGen.g:505:4: ^(p= PrefixedBlock ID p= ID ( block | compoundStatement ) objectGenStatement )
            {
            	p=(SimSharpTreeNode)Match(input,PrefixedBlock,FOLLOW_PrefixedBlock_in_prefixedBlock1053); if (state.failed) return ;

            	Match(input, Token.DOWN, null); if (state.failed) return ;
            	Match(input,ID,FOLLOW_ID_in_prefixedBlock1058); if (state.failed) return ;
            	p=(SimSharpTreeNode)Match(input,ID,FOLLOW_ID_in_prefixedBlock1065); if (state.failed) return ;
            	if ( (state.backtracking==0) )
            	{

            	  		c = p.Symbol as TypeSymbol;
            	  	  	//cg.CreateMetadata(c);
            	  	  	ctx.Push(c);
            	  	  			
            	  	  	CtorSymbol ctor = c.GetCtor();
            	  	  	ctx.Push(ctor);
            	  	  	//cg.CreateMetadata(ctor);
            	  	  	cg.ReturnFromProc(); 
            	  		//cg.CreateType(c);
            	  		ctx.Pop(); //Ctor
            	  	  	
            	  		//push the prolog
            	  		MethodSymbol prolog = c.ResolveMethod("Prolog");
            	  		ctx.Push(prolog);
            	  		
            	  		cg.LoadThis();
            	  		cg.CallBase(prolog);
            	  		
            	}
            	// C:\\work\\simsharp\\Src\\Ssc\\SimSharpGen.g:528:3: ( block | compoundStatement )
            	int alt15 = 2;
            	int LA15_0 = input.LA(1);

            	if ( (LA15_0 == Block) )
            	{
            	    alt15 = 1;
            	}
            	else if ( (LA15_0 == CompoundStatement) )
            	{
            	    alt15 = 2;
            	}
            	else 
            	{
            	    if ( state.backtracking > 0 ) {state.failed = true; return ;}
            	    NoViableAltException nvae_d15s0 =
            	        new NoViableAltException("", 15, 0, input);

            	    throw nvae_d15s0;
            	}
            	switch (alt15) 
            	{
            	    case 1 :
            	        // C:\\work\\simsharp\\Src\\Ssc\\SimSharpGen.g:528:4: block
            	        {
            	        	PushFollow(FOLLOW_block_in_prefixedBlock1077);
            	        	block();
            	        	state.followingStackPointer--;
            	        	if (state.failed) return ;

            	        }
            	        break;
            	    case 2 :
            	        // C:\\work\\simsharp\\Src\\Ssc\\SimSharpGen.g:528:10: compoundStatement
            	        {
            	        	PushFollow(FOLLOW_compoundStatement_in_prefixedBlock1079);
            	        	compoundStatement();
            	        	state.followingStackPointer--;
            	        	if (state.failed) return ;

            	        }
            	        break;

            	}

            	if ( (state.backtracking==0) )
            	{
            	   
            	  		cg.ReturnFromProc(); 
            	  		
            	  		//cg.CreateType(c);
            	  		
            	  		ctx.Pop(); //Prolog
            	  		ctx.Pop(); //Class
            	  		
            	}
            	PushFollow(FOLLOW_objectGenStatement_in_prefixedBlock1091);
            	objectGenStatement();
            	state.followingStackPointer--;
            	if (state.failed) return ;

            	Match(input, Token.UP, null); if (state.failed) return ;

            }

        }
        catch (RecognitionException re) 
    	{
            ReportError(re);
            Recover(input,re);
        }
        finally 
    	{
        }
        return ;
    }
    // $ANTLR end "prefixedBlock"


    // $ANTLR start "declaration"
    // C:\\work\\simsharp\\Src\\Ssc\\SimSharpGen.g:542:1: declaration : ( varDecl | procDecl | classDecl | arrayDecl | switchDecl );
    public void declaration() // throws RecognitionException [1]
    {   
        try 
    	{
            // C:\\work\\simsharp\\Src\\Ssc\\SimSharpGen.g:543:2: ( varDecl | procDecl | classDecl | arrayDecl | switchDecl )
            int alt16 = 5;
            switch ( input.LA(1) ) 
            {
            case VarDecl:
            	{
                alt16 = 1;
                }
                break;
            case ProcDecl:
            	{
                alt16 = 2;
                }
                break;
            case ClassDecl:
            	{
                alt16 = 3;
                }
                break;
            case ArrayDecl:
            	{
                alt16 = 4;
                }
                break;
            case SWITCH:
            	{
                alt16 = 5;
                }
                break;
            	default:
            	    if ( state.backtracking > 0 ) {state.failed = true; return ;}
            	    NoViableAltException nvae_d16s0 =
            	        new NoViableAltException("", 16, 0, input);

            	    throw nvae_d16s0;
            }

            switch (alt16) 
            {
                case 1 :
                    // C:\\work\\simsharp\\Src\\Ssc\\SimSharpGen.g:543:4: varDecl
                    {
                    	PushFollow(FOLLOW_varDecl_in_declaration1110);
                    	varDecl();
                    	state.followingStackPointer--;
                    	if (state.failed) return ;

                    }
                    break;
                case 2 :
                    // C:\\work\\simsharp\\Src\\Ssc\\SimSharpGen.g:544:4: procDecl
                    {
                    	PushFollow(FOLLOW_procDecl_in_declaration1115);
                    	procDecl();
                    	state.followingStackPointer--;
                    	if (state.failed) return ;

                    }
                    break;
                case 3 :
                    // C:\\work\\simsharp\\Src\\Ssc\\SimSharpGen.g:545:4: classDecl
                    {
                    	PushFollow(FOLLOW_classDecl_in_declaration1120);
                    	classDecl();
                    	state.followingStackPointer--;
                    	if (state.failed) return ;

                    }
                    break;
                case 4 :
                    // C:\\work\\simsharp\\Src\\Ssc\\SimSharpGen.g:546:4: arrayDecl
                    {
                    	PushFollow(FOLLOW_arrayDecl_in_declaration1125);
                    	arrayDecl();
                    	state.followingStackPointer--;
                    	if (state.failed) return ;

                    }
                    break;
                case 5 :
                    // C:\\work\\simsharp\\Src\\Ssc\\SimSharpGen.g:547:4: switchDecl
                    {
                    	PushFollow(FOLLOW_switchDecl_in_declaration1130);
                    	switchDecl();
                    	state.followingStackPointer--;
                    	if (state.failed) return ;

                    }
                    break;

            }
        }
        catch (RecognitionException re) 
    	{
            ReportError(re);
            Recover(input,re);
        }
        finally 
    	{
        }
        return ;
    }
    // $ANTLR end "declaration"


    // $ANTLR start "switchDecl"
    // C:\\work\\simsharp\\Src\\Ssc\\SimSharpGen.g:550:1: switchDecl : ^( SWITCH i= ID switchList[sw] ) ;
    public void switchDecl() // throws RecognitionException [1]
    {   
        SimSharpTreeNode i = null;


        SwitchSymbol sw = null;

        try 
    	{
            // C:\\work\\simsharp\\Src\\Ssc\\SimSharpGen.g:554:2: ( ^( SWITCH i= ID switchList[sw] ) )
            // C:\\work\\simsharp\\Src\\Ssc\\SimSharpGen.g:554:4: ^( SWITCH i= ID switchList[sw] )
            {
            	Match(input,SWITCH,FOLLOW_SWITCH_in_switchDecl1147); if (state.failed) return ;

            	Match(input, Token.DOWN, null); if (state.failed) return ;
            	i=(SimSharpTreeNode)Match(input,ID,FOLLOW_ID_in_switchDecl1154); if (state.failed) return ;
            	if ( (state.backtracking==0) )
            	{

            	  		  sw = i.Symbol as SwitchSymbol;
            	  		
            	}
            	PushFollow(FOLLOW_switchList_in_switchDecl1163);
            	switchList(sw);
            	state.followingStackPointer--;
            	if (state.failed) return ;
            	if ( (state.backtracking==0) )
            	{

            	  		
            	  		
            	}

            	Match(input, Token.UP, null); if (state.failed) return ;

            }

        }
        catch (RecognitionException re) 
    	{
            ReportError(re);
            Recover(input,re);
        }
        finally 
    	{
        }
        return ;
    }
    // $ANTLR end "switchDecl"


    // $ANTLR start "switchList"
    // C:\\work\\simsharp\\Src\\Ssc\\SimSharpGen.g:567:1: switchList[SwitchSymbol sw] : ^( SwitchList (i= ID )* ) ;
    public void switchList(SwitchSymbol sw) // throws RecognitionException [1]
    {   
        SimSharpTreeNode i = null;

        try 
    	{
            // C:\\work\\simsharp\\Src\\Ssc\\SimSharpGen.g:568:2: ( ^( SwitchList (i= ID )* ) )
            // C:\\work\\simsharp\\Src\\Ssc\\SimSharpGen.g:568:4: ^( SwitchList (i= ID )* )
            {
            	Match(input,SwitchList,FOLLOW_SwitchList_in_switchList1189); if (state.failed) return ;

            	if ( input.LA(1) == Token.DOWN )
            	{
            	    Match(input, Token.DOWN, null); if (state.failed) return ;
            	    // C:\\work\\simsharp\\Src\\Ssc\\SimSharpGen.g:569:3: (i= ID )*
            	    do 
            	    {
            	        int alt17 = 2;
            	        int LA17_0 = input.LA(1);

            	        if ( (LA17_0 == ID) )
            	        {
            	            alt17 = 1;
            	        }


            	        switch (alt17) 
            	    	{
            	    		case 1 :
            	    		    // C:\\work\\simsharp\\Src\\Ssc\\SimSharpGen.g:569:4: i= ID
            	    		    {
            	    		    	i=(SimSharpTreeNode)Match(input,ID,FOLLOW_ID_in_switchList1197); if (state.failed) return ;
            	    		    	if ( (state.backtracking==0) )
            	    		    	{

            	    		    	  		  LabelSymbol labSym = ctx.Scope.ResolveLabel(((i != null) ? i.Text : null));
            	    		    	  		  if (labSym == null) errMan.ReportError("CodeGen", i.Line, i.CharPositionInLine, "Unrecognized label identifier '" + ((i != null) ? i.Text : null) + "'");
            	    		    	  		  else
            	    		    	  		  {
            	    		    	  		    cg.DefineLabel(labSym);
            	    		    	  		    sw.JumpPoints.Add(labSym);
            	    		    	  		  }
            	    		    	  		
            	    		    	}

            	    		    }
            	    		    break;

            	    		default:
            	    		    goto loop17;
            	        }
            	    } while (true);

            	    loop17:
            	    	;	// Stops C# compiler whining that label 'loop17' has no statements


            	    Match(input, Token.UP, null); if (state.failed) return ;
            	}

            }

        }
        catch (RecognitionException re) 
    	{
            ReportError(re);
            Recover(input,re);
        }
        finally 
    	{
        }
        return ;
    }
    // $ANTLR end "switchList"


    // $ANTLR start "arrayDecl"
    // C:\\work\\simsharp\\Src\\Ssc\\SimSharpGen.g:583:1: arrayDecl : ^( ArrayDecl ( type )? ( array )+ ) ;
    public void arrayDecl() // throws RecognitionException [1]
    {   
        try 
    	{
            // C:\\work\\simsharp\\Src\\Ssc\\SimSharpGen.g:584:2: ( ^( ArrayDecl ( type )? ( array )+ ) )
            // C:\\work\\simsharp\\Src\\Ssc\\SimSharpGen.g:584:4: ^( ArrayDecl ( type )? ( array )+ )
            {
            	Match(input,ArrayDecl,FOLLOW_ArrayDecl_in_arrayDecl1226); if (state.failed) return ;

            	Match(input, Token.DOWN, null); if (state.failed) return ;
            	// C:\\work\\simsharp\\Src\\Ssc\\SimSharpGen.g:584:16: ( type )?
            	int alt18 = 2;
            	int LA18_0 = input.LA(1);

            	if ( (LA18_0 == Type) )
            	{
            	    alt18 = 1;
            	}
            	switch (alt18) 
            	{
            	    case 1 :
            	        // C:\\work\\simsharp\\Src\\Ssc\\SimSharpGen.g:584:17: type
            	        {
            	        	PushFollow(FOLLOW_type_in_arrayDecl1229);
            	        	type();
            	        	state.followingStackPointer--;
            	        	if (state.failed) return ;

            	        }
            	        break;

            	}

            	// C:\\work\\simsharp\\Src\\Ssc\\SimSharpGen.g:584:24: ( array )+
            	int cnt19 = 0;
            	do 
            	{
            	    int alt19 = 2;
            	    int LA19_0 = input.LA(1);

            	    if ( (LA19_0 == Array) )
            	    {
            	        alt19 = 1;
            	    }


            	    switch (alt19) 
            		{
            			case 1 :
            			    // C:\\work\\simsharp\\Src\\Ssc\\SimSharpGen.g:584:24: array
            			    {
            			    	PushFollow(FOLLOW_array_in_arrayDecl1233);
            			    	array();
            			    	state.followingStackPointer--;
            			    	if (state.failed) return ;

            			    }
            			    break;

            			default:
            			    if ( cnt19 >= 1 ) goto loop19;
            			    if ( state.backtracking > 0 ) {state.failed = true; return ;}
            		            EarlyExitException eee19 =
            		                new EarlyExitException(19, input);
            		            throw eee19;
            	    }
            	    cnt19++;
            	} while (true);

            	loop19:
            		;	// Stops C# compiler whinging that label 'loop19' has no statements


            	Match(input, Token.UP, null); if (state.failed) return ;

            }

        }
        catch (RecognitionException re) 
    	{
            ReportError(re);
            Recover(input,re);
        }
        finally 
    	{
        }
        return ;
    }
    // $ANTLR end "arrayDecl"


    // $ANTLR start "array"
    // C:\\work\\simsharp\\Src\\Ssc\\SimSharpGen.g:587:1: array : ^( Array i= ID ( arrayDim[dim++, dimSizeVector, dimStartVector] )+ ) ;
    public void array() // throws RecognitionException [1]
    {   
        SimSharpTreeNode i = null;


        Symbol s = null;			//the array variable
        VariableSymbol dimSizeVector = null;	//size of each dimention
        VariableSymbol dimStartVector = null;	//start index of each dimention
        int dim = 0; //current dimention

        try 
    	{
            // C:\\work\\simsharp\\Src\\Ssc\\SimSharpGen.g:594:2: ( ^( Array i= ID ( arrayDim[dim++, dimSizeVector, dimStartVector] )+ ) )
            // C:\\work\\simsharp\\Src\\Ssc\\SimSharpGen.g:594:4: ^( Array i= ID ( arrayDim[dim++, dimSizeVector, dimStartVector] )+ )
            {
            	Match(input,Array,FOLLOW_Array_in_array1254); if (state.failed) return ;

            	Match(input, Token.DOWN, null); if (state.failed) return ;
            	i=(SimSharpTreeNode)Match(input,ID,FOLLOW_ID_in_array1261); if (state.failed) return ;
            	if ( (state.backtracking==0) )
            	{

            	  		  s = i.Symbol;

            	  		  if (!s.Type.IsArray) errMan.ReportError("CodeGen", i.Line, i.CharPositionInLine, "'" + i.Text + "' is not an array.");
            	  		  
            	  		  //cg.CreateMetadata(s.Type);
            	  		  
            	  		  if (!(s is FieldSymbol)) cg.CreateMetadata(s);

            	  		  //{
            	  		  //  FieldSymbol f = (FieldSymbol) s;

            	  		    //We need to load owner of the field in order to store the array when it is created.
            	  		    cg.LoadThisOrInspect(s);    
            	  		    dimSizeVector = cg.CreateIntVector(s.Type.Dimentions);
            	  		    dimStartVector = cg.CreateIntVector(s.Type.Dimentions);
            	  		  //}
            	  		  //else errMan.ReportError("CodeGen", i.Line, i.CharPositionInLine, "We only support fields in Array declarations '" + i.Text + "'");
            	  		
            	}
            	// C:\\work\\simsharp\\Src\\Ssc\\SimSharpGen.g:615:3: ( arrayDim[dim++, dimSizeVector, dimStartVector] )+
            	int cnt20 = 0;
            	do 
            	{
            	    int alt20 = 2;
            	    int LA20_0 = input.LA(1);

            	    if ( (LA20_0 == ArrayDim) )
            	    {
            	        alt20 = 1;
            	    }


            	    switch (alt20) 
            		{
            			case 1 :
            			    // C:\\work\\simsharp\\Src\\Ssc\\SimSharpGen.g:615:3: arrayDim[dim++, dimSizeVector, dimStartVector]
            			    {
            			    	PushFollow(FOLLOW_arrayDim_in_array1269);
            			    	arrayDim(dim++, dimSizeVector, dimStartVector);
            			    	state.followingStackPointer--;
            			    	if (state.failed) return ;

            			    }
            			    break;

            			default:
            			    if ( cnt20 >= 1 ) goto loop20;
            			    if ( state.backtracking > 0 ) {state.failed = true; return ;}
            		            EarlyExitException eee20 =
            		                new EarlyExitException(20, input);
            		            throw eee20;
            	    }
            	    cnt20++;
            	} while (true);

            	loop20:
            		;	// Stops C# compiler whinging that label 'loop20' has no statements


            	Match(input, Token.UP, null); if (state.failed) return ;
            	if ( (state.backtracking==0) )
            	{

            	  	   	  cg.CreateArray(s.Type.ElementType, dimSizeVector, dimStartVector);
            	  	   	  cg.RefAssign(s, SymbolTable.Array);
            	  	   	
            	}

            }

        }
        catch (RecognitionException re) 
    	{
            ReportError(re);
            Recover(input,re);
        }
        finally 
    	{
        }
        return ;
    }
    // $ANTLR end "array"


    // $ANTLR start "arrayDim"
    // C:\\work\\simsharp\\Src\\Ssc\\SimSharpGen.g:622:1: arrayDim[int dim, VariableSymbol sizeV, VariableSymbol startV] : ^( ArrayDim a= expression b= expression ) ;
    public void arrayDim(int dim, VariableSymbol sizeV, VariableSymbol startV) // throws RecognitionException [1]
    {   
        SimSharpGen.expression_return a = default(SimSharpGen.expression_return);

        SimSharpGen.expression_return b = default(SimSharpGen.expression_return);


        try 
    	{
            // C:\\work\\simsharp\\Src\\Ssc\\SimSharpGen.g:623:2: ( ^( ArrayDim a= expression b= expression ) )
            // C:\\work\\simsharp\\Src\\Ssc\\SimSharpGen.g:623:4: ^( ArrayDim a= expression b= expression )
            {
            	Match(input,ArrayDim,FOLLOW_ArrayDim_in_arrayDim1293); if (state.failed) return ;

            	if ( (state.backtracking==0) )
            	{

            	  		  cg.Load(startV);
            	  		  cg.LoadConst(dim);
            	  		
            	}

            	Match(input, Token.DOWN, null); if (state.failed) return ;
            	PushFollow(FOLLOW_expression_in_arrayDim1304);
            	a = expression();
            	state.followingStackPointer--;
            	if (state.failed) return ;
            	if ( (state.backtracking==0) )
            	{

            	  		  cg.StoreVectorElement(startV.Type.ElementType);
            	  		  
            	  		  cg.Load(sizeV);
            	  		  cg.LoadConst(dim);
            	  		
            	}
            	PushFollow(FOLLOW_expression_in_arrayDim1315);
            	b = expression();
            	state.followingStackPointer--;
            	if (state.failed) return ;
            	if ( (state.backtracking==0) )
            	{

            	  		  cg.LoadVectorElement(startV, dim);
            	  		  cg.ExprMinus();
            	  		  cg.LoadConst(1);
            	  		  cg.ExprPlus();
            	  		  cg.StoreVectorElement(sizeV.Type.ElementType);
            	  		
            	}

            	Match(input, Token.UP, null); if (state.failed) return ;

            }

        }
        catch (RecognitionException re) 
    	{
            ReportError(re);
            Recover(input,re);
        }
        finally 
    	{
        }
        return ;
    }
    // $ANTLR end "arrayDim"


    // $ANTLR start "classDecl"
    // C:\\work\\simsharp\\Src\\Ssc\\SimSharpGen.g:646:1: classDecl : ^( ClassDecl ( ID )? CLASS i= ID ( formalParameters[true] )? ( valueParams )? ( specification )? classBody ) ;
    public void classDecl() // throws RecognitionException [1]
    {   
        SimSharpTreeNode i = null;


        TypeSymbol c = null;

        try 
    	{
            // C:\\work\\simsharp\\Src\\Ssc\\SimSharpGen.g:650:2: ( ^( ClassDecl ( ID )? CLASS i= ID ( formalParameters[true] )? ( valueParams )? ( specification )? classBody ) )
            // C:\\work\\simsharp\\Src\\Ssc\\SimSharpGen.g:650:4: ^( ClassDecl ( ID )? CLASS i= ID ( formalParameters[true] )? ( valueParams )? ( specification )? classBody )
            {
            	Match(input,ClassDecl,FOLLOW_ClassDecl_in_classDecl1343); if (state.failed) return ;

            	Match(input, Token.DOWN, null); if (state.failed) return ;
            	// C:\\work\\simsharp\\Src\\Ssc\\SimSharpGen.g:650:16: ( ID )?
            	int alt21 = 2;
            	int LA21_0 = input.LA(1);

            	if ( (LA21_0 == ID) )
            	{
            	    alt21 = 1;
            	}
            	switch (alt21) 
            	{
            	    case 1 :
            	        // C:\\work\\simsharp\\Src\\Ssc\\SimSharpGen.g:650:16: ID
            	        {
            	        	Match(input,ID,FOLLOW_ID_in_classDecl1345); if (state.failed) return ;

            	        }
            	        break;

            	}

            	Match(input,CLASS,FOLLOW_CLASS_in_classDecl1348); if (state.failed) return ;
            	i=(SimSharpTreeNode)Match(input,ID,FOLLOW_ID_in_classDecl1355); if (state.failed) return ;
            	if ( (state.backtracking==0) )
            	{
            	  	
            	  		c = i.Symbol as TypeSymbol;
            	  	  	//cg.CreateMetadata(c);
            	  	  	ctx.Push(c);
            	  	  			
            	  	  	CtorSymbol ctor = c.GetCtor();
            	  	  	ctx.Push(ctor);
            	  	  	//cg.CreateMetadata(ctor);
            	  	  	
            	}
            	// C:\\work\\simsharp\\Src\\Ssc\\SimSharpGen.g:661:5: ( formalParameters[true] )?
            	int alt22 = 2;
            	int LA22_0 = input.LA(1);

            	if ( (LA22_0 == FormalParameters) )
            	{
            	    alt22 = 1;
            	}
            	switch (alt22) 
            	{
            	    case 1 :
            	        // C:\\work\\simsharp\\Src\\Ssc\\SimSharpGen.g:661:6: formalParameters[true]
            	        {
            	        	PushFollow(FOLLOW_formalParameters_in_classDecl1367);
            	        	formalParameters(true);
            	        	state.followingStackPointer--;
            	        	if (state.failed) return ;

            	        }
            	        break;

            	}

            	// C:\\work\\simsharp\\Src\\Ssc\\SimSharpGen.g:662:5: ( valueParams )?
            	int alt23 = 2;
            	int LA23_0 = input.LA(1);

            	if ( (LA23_0 == VALUE) )
            	{
            	    alt23 = 1;
            	}
            	switch (alt23) 
            	{
            	    case 1 :
            	        // C:\\work\\simsharp\\Src\\Ssc\\SimSharpGen.g:662:6: valueParams
            	        {
            	        	PushFollow(FOLLOW_valueParams_in_classDecl1377);
            	        	valueParams();
            	        	state.followingStackPointer--;
            	        	if (state.failed) return ;

            	        }
            	        break;

            	}

            	// C:\\work\\simsharp\\Src\\Ssc\\SimSharpGen.g:663:5: ( specification )?
            	int alt24 = 2;
            	int LA24_0 = input.LA(1);

            	if ( (LA24_0 == Specification) )
            	{
            	    alt24 = 1;
            	}
            	switch (alt24) 
            	{
            	    case 1 :
            	        // C:\\work\\simsharp\\Src\\Ssc\\SimSharpGen.g:663:6: specification
            	        {
            	        	PushFollow(FOLLOW_specification_in_classDecl1386);
            	        	specification();
            	        	state.followingStackPointer--;
            	        	if (state.failed) return ;

            	        }
            	        break;

            	}

            	PushFollow(FOLLOW_classBody_in_classDecl1392);
            	classBody();
            	state.followingStackPointer--;
            	if (state.failed) return ;
            	if ( (state.backtracking==0) )
            	{
            	   
            	  		cg.ReturnFromProc(); 
            	  		
            	  		//cg.CreateType(c);
            	  		
            	  		ctx.Pop(); //Ctor
            	  		ctx.Pop(); //Class
            	  		
            	}

            	Match(input, Token.UP, null); if (state.failed) return ;

            }

        }
        catch (RecognitionException re) 
    	{
            ReportError(re);
            Recover(input,re);
        }
        finally 
    	{
        }
        return ;
    }
    // $ANTLR end "classDecl"


    // $ANTLR start "classBody"
    // C:\\work\\simsharp\\Src\\Ssc\\SimSharpGen.g:676:1: classBody : ^( ClassBody prolog ( epilog )? ) ;
    public void classBody() // throws RecognitionException [1]
    {   
        try 
    	{
            // C:\\work\\simsharp\\Src\\Ssc\\SimSharpGen.g:677:2: ( ^( ClassBody prolog ( epilog )? ) )
            // C:\\work\\simsharp\\Src\\Ssc\\SimSharpGen.g:677:4: ^( ClassBody prolog ( epilog )? )
            {
            	Match(input,ClassBody,FOLLOW_ClassBody_in_classBody1415); if (state.failed) return ;

            	Match(input, Token.DOWN, null); if (state.failed) return ;
            	PushFollow(FOLLOW_prolog_in_classBody1417);
            	prolog();
            	state.followingStackPointer--;
            	if (state.failed) return ;
            	// C:\\work\\simsharp\\Src\\Ssc\\SimSharpGen.g:677:23: ( epilog )?
            	int alt25 = 2;
            	int LA25_0 = input.LA(1);

            	if ( (LA25_0 == Epilog) )
            	{
            	    alt25 = 1;
            	}
            	switch (alt25) 
            	{
            	    case 1 :
            	        // C:\\work\\simsharp\\Src\\Ssc\\SimSharpGen.g:677:23: epilog
            	        {
            	        	PushFollow(FOLLOW_epilog_in_classBody1419);
            	        	epilog();
            	        	state.followingStackPointer--;
            	        	if (state.failed) return ;

            	        }
            	        break;

            	}


            	Match(input, Token.UP, null); if (state.failed) return ;

            }

        }
        catch (RecognitionException re) 
    	{
            ReportError(re);
            Recover(input,re);
        }
        finally 
    	{
        }
        return ;
    }
    // $ANTLR end "classBody"


    // $ANTLR start "prolog"
    // C:\\work\\simsharp\\Src\\Ssc\\SimSharpGen.g:680:1: prolog : ^(p= Prolog ( declaration )* ( statement )* ) ;
    public void prolog() // throws RecognitionException [1]
    {   
        SimSharpTreeNode p = null;

        try 
    	{
            // C:\\work\\simsharp\\Src\\Ssc\\SimSharpGen.g:680:8: ( ^(p= Prolog ( declaration )* ( statement )* ) )
            // C:\\work\\simsharp\\Src\\Ssc\\SimSharpGen.g:680:10: ^(p= Prolog ( declaration )* ( statement )* )
            {
            	p=(SimSharpTreeNode)Match(input,Prolog,FOLLOW_Prolog_in_prolog1435); if (state.failed) return ;

            	if ( (state.backtracking==0) )
            	{

            	  		//pop off ctx)
            	  		cg.ReturnFromProc();
            	  		ctx.Pop();
            	  		
            	  		//push the prolog
            	  		MethodSymbol prolog = p.Symbol as MethodSymbol;
            	  		ctx.Push(prolog);
            	  		//cg.CreateMetadata(prolog);
            	  		cg.LoadThis();
            	  		cg.CallBase(prolog);
            	  		
            	}

            	if ( input.LA(1) == Token.DOWN )
            	{
            	    Match(input, Token.DOWN, null); if (state.failed) return ;
            	    // C:\\work\\simsharp\\Src\\Ssc\\SimSharpGen.g:693:3: ( declaration )*
            	    do 
            	    {
            	        int alt26 = 2;
            	        int LA26_0 = input.LA(1);

            	        if ( (LA26_0 == VarDecl || LA26_0 == ProcDecl || LA26_0 == ClassDecl || LA26_0 == ArrayDecl || LA26_0 == SWITCH) )
            	        {
            	            alt26 = 1;
            	        }


            	        switch (alt26) 
            	    	{
            	    		case 1 :
            	    		    // C:\\work\\simsharp\\Src\\Ssc\\SimSharpGen.g:693:3: declaration
            	    		    {
            	    		    	PushFollow(FOLLOW_declaration_in_prolog1444);
            	    		    	declaration();
            	    		    	state.followingStackPointer--;
            	    		    	if (state.failed) return ;

            	    		    }
            	    		    break;

            	    		default:
            	    		    goto loop26;
            	        }
            	    } while (true);

            	    loop26:
            	    	;	// Stops C# compiler whining that label 'loop26' has no statements

            	    // C:\\work\\simsharp\\Src\\Ssc\\SimSharpGen.g:694:3: ( statement )*
            	    do 
            	    {
            	        int alt27 = 2;
            	        int LA27_0 = input.LA(1);

            	        if ( (LA27_0 == Block || LA27_0 == CompoundStatement || LA27_0 == MethCall || (LA27_0 >= Label && LA27_0 <= GoTo) || LA27_0 == PrefixedBlock || (LA27_0 >= VALASSIGN && LA27_0 <= REFASSIGN) || LA27_0 == IF || LA27_0 == WHILE || LA27_0 == FOR || LA27_0 == INSPECT || LA27_0 == NEW) )
            	        {
            	            alt27 = 1;
            	        }


            	        switch (alt27) 
            	    	{
            	    		case 1 :
            	    		    // C:\\work\\simsharp\\Src\\Ssc\\SimSharpGen.g:694:3: statement
            	    		    {
            	    		    	PushFollow(FOLLOW_statement_in_prolog1450);
            	    		    	statement();
            	    		    	state.followingStackPointer--;
            	    		    	if (state.failed) return ;

            	    		    }
            	    		    break;

            	    		default:
            	    		    goto loop27;
            	        }
            	    } while (true);

            	    loop27:
            	    	;	// Stops C# compiler whining that label 'loop27' has no statements


            	    Match(input, Token.UP, null); if (state.failed) return ;
            	}

            }

        }
        catch (RecognitionException re) 
    	{
            ReportError(re);
            Recover(input,re);
        }
        finally 
    	{
        }
        return ;
    }
    // $ANTLR end "prolog"


    // $ANTLR start "epilog"
    // C:\\work\\simsharp\\Src\\Ssc\\SimSharpGen.g:697:1: epilog : ^(e= Epilog ( statement )* ) ;
    public void epilog() // throws RecognitionException [1]
    {   
        SimSharpTreeNode e = null;


        MethodSymbol emeth = null;

        try 
    	{
            // C:\\work\\simsharp\\Src\\Ssc\\SimSharpGen.g:701:2: ( ^(e= Epilog ( statement )* ) )
            // C:\\work\\simsharp\\Src\\Ssc\\SimSharpGen.g:701:4: ^(e= Epilog ( statement )* )
            {
            	e=(SimSharpTreeNode)Match(input,Epilog,FOLLOW_Epilog_in_epilog1474); if (state.failed) return ;

            	if ( (state.backtracking==0) )
            	{

            	  		//pop off prolog)
            	  		cg.ReturnFromProc();
            	  		ctx.Pop();   	
            	  		
            	  		//push the epilog
            	  		emeth = e.Symbol as MethodSymbol;
            	  		ctx.Push(emeth);
            	  		//cg.CreateMetadata(epilog);	
            	  		
            	}

            	if ( input.LA(1) == Token.DOWN )
            	{
            	    Match(input, Token.DOWN, null); if (state.failed) return ;
            	    // C:\\work\\simsharp\\Src\\Ssc\\SimSharpGen.g:712:3: ( statement )*
            	    do 
            	    {
            	        int alt28 = 2;
            	        int LA28_0 = input.LA(1);

            	        if ( (LA28_0 == Block || LA28_0 == CompoundStatement || LA28_0 == MethCall || (LA28_0 >= Label && LA28_0 <= GoTo) || LA28_0 == PrefixedBlock || (LA28_0 >= VALASSIGN && LA28_0 <= REFASSIGN) || LA28_0 == IF || LA28_0 == WHILE || LA28_0 == FOR || LA28_0 == INSPECT || LA28_0 == NEW) )
            	        {
            	            alt28 = 1;
            	        }


            	        switch (alt28) 
            	    	{
            	    		case 1 :
            	    		    // C:\\work\\simsharp\\Src\\Ssc\\SimSharpGen.g:712:3: statement
            	    		    {
            	    		    	PushFollow(FOLLOW_statement_in_epilog1483);
            	    		    	statement();
            	    		    	state.followingStackPointer--;
            	    		    	if (state.failed) return ;

            	    		    }
            	    		    break;

            	    		default:
            	    		    goto loop28;
            	        }
            	    } while (true);

            	    loop28:
            	    	;	// Stops C# compiler whining that label 'loop28' has no statements


            	    Match(input, Token.UP, null); if (state.failed) return ;
            	}
            	if ( (state.backtracking==0) )
            	{

            	  		cg.LoadThis();
            	  		cg.CallBase(emeth);
            	  		
            	}

            }

        }
        catch (RecognitionException re) 
    	{
            ReportError(re);
            Recover(input,re);
        }
        finally 
    	{
        }
        return ;
    }
    // $ANTLR end "epilog"


    // $ANTLR start "varDecl"
    // C:\\work\\simsharp\\Src\\Ssc\\SimSharpGen.g:719:1: varDecl : ^( VarDecl t= type ( ^( TypeList (i= ID | ^( ConstElement i= ID r= NUM_REAL ) )* ) ) ) ;
    public void varDecl() // throws RecognitionException [1]
    {   
        SimSharpTreeNode i = null;
        SimSharpTreeNode r = null;

        try 
    	{
            // C:\\work\\simsharp\\Src\\Ssc\\SimSharpGen.g:719:9: ( ^( VarDecl t= type ( ^( TypeList (i= ID | ^( ConstElement i= ID r= NUM_REAL ) )* ) ) ) )
            // C:\\work\\simsharp\\Src\\Ssc\\SimSharpGen.g:719:11: ^( VarDecl t= type ( ^( TypeList (i= ID | ^( ConstElement i= ID r= NUM_REAL ) )* ) ) )
            {
            	Match(input,VarDecl,FOLLOW_VarDecl_in_varDecl1503); if (state.failed) return ;

            	Match(input, Token.DOWN, null); if (state.failed) return ;
            	PushFollow(FOLLOW_type_in_varDecl1507);
            	type();
            	state.followingStackPointer--;
            	if (state.failed) return ;
            	// C:\\work\\simsharp\\Src\\Ssc\\SimSharpGen.g:720:3: ( ^( TypeList (i= ID | ^( ConstElement i= ID r= NUM_REAL ) )* ) )
            	// C:\\work\\simsharp\\Src\\Ssc\\SimSharpGen.g:720:4: ^( TypeList (i= ID | ^( ConstElement i= ID r= NUM_REAL ) )* )
            	{
            		Match(input,TypeList,FOLLOW_TypeList_in_varDecl1514); if (state.failed) return ;

            		if ( input.LA(1) == Token.DOWN )
            		{
            		    Match(input, Token.DOWN, null); if (state.failed) return ;
            		    // C:\\work\\simsharp\\Src\\Ssc\\SimSharpGen.g:721:4: (i= ID | ^( ConstElement i= ID r= NUM_REAL ) )*
            		    do 
            		    {
            		        int alt29 = 3;
            		        int LA29_0 = input.LA(1);

            		        if ( (LA29_0 == ID) )
            		        {
            		            alt29 = 1;
            		        }
            		        else if ( (LA29_0 == ConstElement) )
            		        {
            		            alt29 = 2;
            		        }


            		        switch (alt29) 
            		    	{
            		    		case 1 :
            		    		    // C:\\work\\simsharp\\Src\\Ssc\\SimSharpGen.g:721:5: i= ID
            		    		    {
            		    		    	i=(SimSharpTreeNode)Match(input,ID,FOLLOW_ID_in_varDecl1523); if (state.failed) return ;
            		    		    	if ( (state.backtracking==0) )
            		    		    	{

            		    		    	  			Symbol s = i.Symbol;
            		    		    	  			if (!(s is FieldSymbol)) cg.CreateMetadata(i.Symbol);
            		    		    	  			
            		    		    	  			//initialize text variables.
            		    		    	  			if (i.Symbol.Type == SymbolTable.Text)
            		    		    	  			{
            		    		    	  			  if (i.Symbol is FieldSymbol)
            		    		    	  			    cg.LoadThisOrInspect(i.Symbol);
            		    		    	  			    
            		    		    	  			  cg.Load(SymbolTable.NoText);
            		    		    	  			  cg.RefAssign(i.Symbol, SymbolTable.Text);
            		    		    	  			}
            		    		    	  			
            		    		    	}

            		    		    }
            		    		    break;
            		    		case 2 :
            		    		    // C:\\work\\simsharp\\Src\\Ssc\\SimSharpGen.g:736:6: ^( ConstElement i= ID r= NUM_REAL )
            		    		    {
            		    		    	Match(input,ConstElement,FOLLOW_ConstElement_in_varDecl1537); if (state.failed) return ;

            		    		    	Match(input, Token.DOWN, null); if (state.failed) return ;
            		    		    	i=(SimSharpTreeNode)Match(input,ID,FOLLOW_ID_in_varDecl1541); if (state.failed) return ;
            		    		    	r=(SimSharpTreeNode)Match(input,NUM_REAL,FOLLOW_NUM_REAL_in_varDecl1545); if (state.failed) return ;

            		    		    	Match(input, Token.UP, null); if (state.failed) return ;

            		    		    }
            		    		    break;

            		    		default:
            		    		    goto loop29;
            		        }
            		    } while (true);

            		    loop29:
            		    	;	// Stops C# compiler whining that label 'loop29' has no statements


            		    Match(input, Token.UP, null); if (state.failed) return ;
            		}

            	}


            	Match(input, Token.UP, null); if (state.failed) return ;

            }

        }
        catch (RecognitionException re) 
    	{
            ReportError(re);
            Recover(input,re);
        }
        finally 
    	{
        }
        return ;
    }
    // $ANTLR end "varDecl"


    // $ANTLR start "procDecl"
    // C:\\work\\simsharp\\Src\\Ssc\\SimSharpGen.g:744:1: procDecl : ^( ProcDecl ( type )? i= ID ( formalParameters[false] )? ( nameParams )? ( valueParams )? ( specification )? procBody ) ;
    public void procDecl() // throws RecognitionException [1]
    {   
        SimSharpTreeNode i = null;


        bool hasType = false;
        MethodSymbol m = null;

        try 
    	{
            // C:\\work\\simsharp\\Src\\Ssc\\SimSharpGen.g:749:2: ( ^( ProcDecl ( type )? i= ID ( formalParameters[false] )? ( nameParams )? ( valueParams )? ( specification )? procBody ) )
            // C:\\work\\simsharp\\Src\\Ssc\\SimSharpGen.g:749:4: ^( ProcDecl ( type )? i= ID ( formalParameters[false] )? ( nameParams )? ( valueParams )? ( specification )? procBody )
            {
            	Match(input,ProcDecl,FOLLOW_ProcDecl_in_procDecl1587); if (state.failed) return ;

            	Match(input, Token.DOWN, null); if (state.failed) return ;
            	// C:\\work\\simsharp\\Src\\Ssc\\SimSharpGen.g:750:5: ( type )?
            	int alt30 = 2;
            	int LA30_0 = input.LA(1);

            	if ( (LA30_0 == Type) )
            	{
            	    alt30 = 1;
            	}
            	switch (alt30) 
            	{
            	    case 1 :
            	        // C:\\work\\simsharp\\Src\\Ssc\\SimSharpGen.g:750:6: type
            	        {
            	        	PushFollow(FOLLOW_type_in_procDecl1595);
            	        	type();
            	        	state.followingStackPointer--;
            	        	if (state.failed) return ;
            	        	if ( (state.backtracking==0) )
            	        	{
            	        	   hasType = true; 
            	        	}

            	        }
            	        break;

            	}

            	i=(SimSharpTreeNode)Match(input,ID,FOLLOW_ID_in_procDecl1605); if (state.failed) return ;
            	if ( (state.backtracking==0) )
            	{

            	  	  	m = (MethodSymbol) i.Symbol; 
            	  	  	//cg.CreateMetadata(m); 
            	  	  	ctx.Push(m);
            	  	  	
            	  	  	if (hasType) cg.CreateMetadata(m.ResolveVariable("_retVal"));
            	  	  	
            	}
            	// C:\\work\\simsharp\\Src\\Ssc\\SimSharpGen.g:759:5: ( formalParameters[false] )?
            	int alt31 = 2;
            	int LA31_0 = input.LA(1);

            	if ( (LA31_0 == FormalParameters) )
            	{
            	    alt31 = 1;
            	}
            	switch (alt31) 
            	{
            	    case 1 :
            	        // C:\\work\\simsharp\\Src\\Ssc\\SimSharpGen.g:759:6: formalParameters[false]
            	        {
            	        	PushFollow(FOLLOW_formalParameters_in_procDecl1619);
            	        	formalParameters(false);
            	        	state.followingStackPointer--;
            	        	if (state.failed) return ;

            	        }
            	        break;

            	}

            	// C:\\work\\simsharp\\Src\\Ssc\\SimSharpGen.g:760:5: ( nameParams )?
            	int alt32 = 2;
            	int LA32_0 = input.LA(1);

            	if ( (LA32_0 == NAME) )
            	{
            	    alt32 = 1;
            	}
            	switch (alt32) 
            	{
            	    case 1 :
            	        // C:\\work\\simsharp\\Src\\Ssc\\SimSharpGen.g:760:6: nameParams
            	        {
            	        	PushFollow(FOLLOW_nameParams_in_procDecl1629);
            	        	nameParams();
            	        	state.followingStackPointer--;
            	        	if (state.failed) return ;

            	        }
            	        break;

            	}

            	// C:\\work\\simsharp\\Src\\Ssc\\SimSharpGen.g:761:5: ( valueParams )?
            	int alt33 = 2;
            	int LA33_0 = input.LA(1);

            	if ( (LA33_0 == VALUE) )
            	{
            	    alt33 = 1;
            	}
            	switch (alt33) 
            	{
            	    case 1 :
            	        // C:\\work\\simsharp\\Src\\Ssc\\SimSharpGen.g:761:6: valueParams
            	        {
            	        	PushFollow(FOLLOW_valueParams_in_procDecl1638);
            	        	valueParams();
            	        	state.followingStackPointer--;
            	        	if (state.failed) return ;

            	        }
            	        break;

            	}

            	// C:\\work\\simsharp\\Src\\Ssc\\SimSharpGen.g:762:5: ( specification )?
            	int alt34 = 2;
            	int LA34_0 = input.LA(1);

            	if ( (LA34_0 == Specification) )
            	{
            	    alt34 = 1;
            	}
            	switch (alt34) 
            	{
            	    case 1 :
            	        // C:\\work\\simsharp\\Src\\Ssc\\SimSharpGen.g:762:6: specification
            	        {
            	        	PushFollow(FOLLOW_specification_in_procDecl1647);
            	        	specification();
            	        	state.followingStackPointer--;
            	        	if (state.failed) return ;

            	        }
            	        break;

            	}

            	PushFollow(FOLLOW_procBody_in_procDecl1655);
            	procBody();
            	state.followingStackPointer--;
            	if (state.failed) return ;

            	Match(input, Token.UP, null); if (state.failed) return ;
            	if ( (state.backtracking==0) )
            	{
            	   
            	  		if (m.Type != SymbolTable.NoType) cg.Load(m.ResolveVariable("_retVal"));
            	  		cg.ReturnFromProc();
            	  		ctx.Pop();  //Proc
            	  		
            	}

            }

        }
        catch (RecognitionException re) 
    	{
            ReportError(re);
            Recover(input,re);
        }
        finally 
    	{
        }
        return ;
    }
    // $ANTLR end "procDecl"


    // $ANTLR start "valueParams"
    // C:\\work\\simsharp\\Src\\Ssc\\SimSharpGen.g:771:1: valueParams : ^( VALUE (i= ID )* ) ;
    public void valueParams() // throws RecognitionException [1]
    {   
        SimSharpTreeNode i = null;

        try 
    	{
            // C:\\work\\simsharp\\Src\\Ssc\\SimSharpGen.g:772:2: ( ^( VALUE (i= ID )* ) )
            // C:\\work\\simsharp\\Src\\Ssc\\SimSharpGen.g:772:4: ^( VALUE (i= ID )* )
            {
            	Match(input,VALUE,FOLLOW_VALUE_in_valueParams1672); if (state.failed) return ;

            	if ( input.LA(1) == Token.DOWN )
            	{
            	    Match(input, Token.DOWN, null); if (state.failed) return ;
            	    // C:\\work\\simsharp\\Src\\Ssc\\SimSharpGen.g:773:3: (i= ID )*
            	    do 
            	    {
            	        int alt35 = 2;
            	        int LA35_0 = input.LA(1);

            	        if ( (LA35_0 == ID) )
            	        {
            	            alt35 = 1;
            	        }


            	        switch (alt35) 
            	    	{
            	    		case 1 :
            	    		    // C:\\work\\simsharp\\Src\\Ssc\\SimSharpGen.g:773:4: i= ID
            	    		    {
            	    		    	i=(SimSharpTreeNode)Match(input,ID,FOLLOW_ID_in_valueParams1679); if (state.failed) return ;
            	    		    	if ( (state.backtracking==0) )
            	    		    	{

            	    		    	  		ArgumentSymbol arg = ctx.Scope.ResolveArgument(i.Text);
            	    		    	  		if (arg != null)
            	    		    	  		  cg.MakeValueParam(arg);
            	    		    	  		else errMan.ReportError("CodeGen", i.Line, i.CharPositionInLine, "Unrecognized parameter '" + i.Text + "'");
            	    		    	  		
            	    		    	}

            	    		    }
            	    		    break;

            	    		default:
            	    		    goto loop35;
            	        }
            	    } while (true);

            	    loop35:
            	    	;	// Stops C# compiler whining that label 'loop35' has no statements


            	    Match(input, Token.UP, null); if (state.failed) return ;
            	}

            }

        }
        catch (RecognitionException re) 
    	{
            ReportError(re);
            Recover(input,re);
        }
        finally 
    	{
        }
        return ;
    }
    // $ANTLR end "valueParams"


    // $ANTLR start "nameParams"
    // C:\\work\\simsharp\\Src\\Ssc\\SimSharpGen.g:784:1: nameParams : ^( NAME ( ID )* ) ;
    public void nameParams() // throws RecognitionException [1]
    {   
        try 
    	{
            // C:\\work\\simsharp\\Src\\Ssc\\SimSharpGen.g:785:2: ( ^( NAME ( ID )* ) )
            // C:\\work\\simsharp\\Src\\Ssc\\SimSharpGen.g:785:4: ^( NAME ( ID )* )
            {
            	Match(input,NAME,FOLLOW_NAME_in_nameParams1707); if (state.failed) return ;

            	if ( input.LA(1) == Token.DOWN )
            	{
            	    Match(input, Token.DOWN, null); if (state.failed) return ;
            	    // C:\\work\\simsharp\\Src\\Ssc\\SimSharpGen.g:785:11: ( ID )*
            	    do 
            	    {
            	        int alt36 = 2;
            	        int LA36_0 = input.LA(1);

            	        if ( (LA36_0 == ID) )
            	        {
            	            alt36 = 1;
            	        }


            	        switch (alt36) 
            	    	{
            	    		case 1 :
            	    		    // C:\\work\\simsharp\\Src\\Ssc\\SimSharpGen.g:785:11: ID
            	    		    {
            	    		    	Match(input,ID,FOLLOW_ID_in_nameParams1709); if (state.failed) return ;

            	    		    }
            	    		    break;

            	    		default:
            	    		    goto loop36;
            	        }
            	    } while (true);

            	    loop36:
            	    	;	// Stops C# compiler whining that label 'loop36' has no statements


            	    Match(input, Token.UP, null); if (state.failed) return ;
            	}

            }

        }
        catch (RecognitionException re) 
    	{
            ReportError(re);
            Recover(input,re);
        }
        finally 
    	{
        }
        return ;
    }
    // $ANTLR end "nameParams"


    // $ANTLR start "formalParameters"
    // C:\\work\\simsharp\\Src\\Ssc\\SimSharpGen.g:788:1: formalParameters[bool constructor] : ^( FormalParameters (i= ID )+ ) ;
    public void formalParameters(bool constructor) // throws RecognitionException [1]
    {   
        SimSharpTreeNode i = null;

        try 
    	{
            // C:\\work\\simsharp\\Src\\Ssc\\SimSharpGen.g:789:2: ( ^( FormalParameters (i= ID )+ ) )
            // C:\\work\\simsharp\\Src\\Ssc\\SimSharpGen.g:789:4: ^( FormalParameters (i= ID )+ )
            {
            	Match(input,FormalParameters,FOLLOW_FormalParameters_in_formalParameters1725); if (state.failed) return ;

            	Match(input, Token.DOWN, null); if (state.failed) return ;
            	// C:\\work\\simsharp\\Src\\Ssc\\SimSharpGen.g:790:3: (i= ID )+
            	int cnt37 = 0;
            	do 
            	{
            	    int alt37 = 2;
            	    int LA37_0 = input.LA(1);

            	    if ( (LA37_0 == ID) )
            	    {
            	        alt37 = 1;
            	    }


            	    switch (alt37) 
            		{
            			case 1 :
            			    // C:\\work\\simsharp\\Src\\Ssc\\SimSharpGen.g:790:4: i= ID
            			    {
            			    	i=(SimSharpTreeNode)Match(input,ID,FOLLOW_ID_in_formalParameters1733); if (state.failed) return ;
            			    	if ( (state.backtracking==0) )
            			    	{

            			    	  		if (constructor)
            			    	  		{
            			    	  		  ArgumentSymbol arg = i.Symbol as ArgumentSymbol;
            			    	  		  FieldSymbol field = ctx.CurrentType.ResolveField(i.Text);
            			    	  		  cg.LoadThis();
            			    	  		  cg.Load(arg);
            			    	  		  cg.Store(field);
            			    	  		}
            			    	  		
            			    	}

            			    }
            			    break;

            			default:
            			    if ( cnt37 >= 1 ) goto loop37;
            			    if ( state.backtracking > 0 ) {state.failed = true; return ;}
            		            EarlyExitException eee37 =
            		                new EarlyExitException(37, input);
            		            throw eee37;
            	    }
            	    cnt37++;
            	} while (true);

            	loop37:
            		;	// Stops C# compiler whinging that label 'loop37' has no statements


            	Match(input, Token.UP, null); if (state.failed) return ;

            }

        }
        catch (RecognitionException re) 
    	{
            ReportError(re);
            Recover(input,re);
        }
        finally 
    	{
        }
        return ;
    }
    // $ANTLR end "formalParameters"


    // $ANTLR start "specification"
    // C:\\work\\simsharp\\Src\\Ssc\\SimSharpGen.g:805:1: specification : ^( Specification ( type ( ID )+ )+ ) ;
    public void specification() // throws RecognitionException [1]
    {   
        try 
    	{
            // C:\\work\\simsharp\\Src\\Ssc\\SimSharpGen.g:806:2: ( ^( Specification ( type ( ID )+ )+ ) )
            // C:\\work\\simsharp\\Src\\Ssc\\SimSharpGen.g:806:4: ^( Specification ( type ( ID )+ )+ )
            {
            	Match(input,Specification,FOLLOW_Specification_in_specification1761); if (state.failed) return ;

            	Match(input, Token.DOWN, null); if (state.failed) return ;
            	// C:\\work\\simsharp\\Src\\Ssc\\SimSharpGen.g:807:7: ( type ( ID )+ )+
            	int cnt39 = 0;
            	do 
            	{
            	    int alt39 = 2;
            	    int LA39_0 = input.LA(1);

            	    if ( (LA39_0 == Type) )
            	    {
            	        alt39 = 1;
            	    }


            	    switch (alt39) 
            		{
            			case 1 :
            			    // C:\\work\\simsharp\\Src\\Ssc\\SimSharpGen.g:807:8: type ( ID )+
            			    {
            			    	PushFollow(FOLLOW_type_in_specification1771);
            			    	type();
            			    	state.followingStackPointer--;
            			    	if (state.failed) return ;
            			    	// C:\\work\\simsharp\\Src\\Ssc\\SimSharpGen.g:808:3: ( ID )+
            			    	int cnt38 = 0;
            			    	do 
            			    	{
            			    	    int alt38 = 2;
            			    	    int LA38_0 = input.LA(1);

            			    	    if ( (LA38_0 == ID) )
            			    	    {
            			    	        alt38 = 1;
            			    	    }


            			    	    switch (alt38) 
            			    		{
            			    			case 1 :
            			    			    // C:\\work\\simsharp\\Src\\Ssc\\SimSharpGen.g:808:4: ID
            			    			    {
            			    			    	Match(input,ID,FOLLOW_ID_in_specification1777); if (state.failed) return ;

            			    			    }
            			    			    break;

            			    			default:
            			    			    if ( cnt38 >= 1 ) goto loop38;
            			    			    if ( state.backtracking > 0 ) {state.failed = true; return ;}
            			    		            EarlyExitException eee38 =
            			    		                new EarlyExitException(38, input);
            			    		            throw eee38;
            			    	    }
            			    	    cnt38++;
            			    	} while (true);

            			    	loop38:
            			    		;	// Stops C# compiler whinging that label 'loop38' has no statements


            			    }
            			    break;

            			default:
            			    if ( cnt39 >= 1 ) goto loop39;
            			    if ( state.backtracking > 0 ) {state.failed = true; return ;}
            		            EarlyExitException eee39 =
            		                new EarlyExitException(39, input);
            		            throw eee39;
            	    }
            	    cnt39++;
            	} while (true);

            	loop39:
            		;	// Stops C# compiler whinging that label 'loop39' has no statements


            	Match(input, Token.UP, null); if (state.failed) return ;

            }

        }
        catch (RecognitionException re) 
    	{
            ReportError(re);
            Recover(input,re);
        }
        finally 
    	{
        }
        return ;
    }
    // $ANTLR end "specification"


    // $ANTLR start "procBody"
    // C:\\work\\simsharp\\Src\\Ssc\\SimSharpGen.g:813:1: procBody : ^( ProcBody statement ) ;
    public void procBody() // throws RecognitionException [1]
    {   
        try 
    	{
            // C:\\work\\simsharp\\Src\\Ssc\\SimSharpGen.g:813:9: ( ^( ProcBody statement ) )
            // C:\\work\\simsharp\\Src\\Ssc\\SimSharpGen.g:813:11: ^( ProcBody statement )
            {
            	Match(input,ProcBody,FOLLOW_ProcBody_in_procBody1807); if (state.failed) return ;

            	Match(input, Token.DOWN, null); if (state.failed) return ;
            	PushFollow(FOLLOW_statement_in_procBody1809);
            	statement();
            	state.followingStackPointer--;
            	if (state.failed) return ;

            	Match(input, Token.UP, null); if (state.failed) return ;

            }

        }
        catch (RecognitionException re) 
    	{
            ReportError(re);
            Recover(input,re);
        }
        finally 
    	{
        }
        return ;
    }
    // $ANTLR end "procBody"


    // $ANTLR start "type"
    // C:\\work\\simsharp\\Src\\Ssc\\SimSharpGen.g:817:1: type : ^( Type ( INTEGER | TEXT | REAL | CHARACTER | REF i= ID | BOOLEAN ) ) ;
    public void type() // throws RecognitionException [1]
    {   
        SimSharpTreeNode i = null;

        try 
    	{
            // C:\\work\\simsharp\\Src\\Ssc\\SimSharpGen.g:817:6: ( ^( Type ( INTEGER | TEXT | REAL | CHARACTER | REF i= ID | BOOLEAN ) ) )
            // C:\\work\\simsharp\\Src\\Ssc\\SimSharpGen.g:817:8: ^( Type ( INTEGER | TEXT | REAL | CHARACTER | REF i= ID | BOOLEAN ) )
            {
            	Match(input,Type,FOLLOW_Type_in_type1823); if (state.failed) return ;

            	Match(input, Token.DOWN, null); if (state.failed) return ;
            	// C:\\work\\simsharp\\Src\\Ssc\\SimSharpGen.g:817:15: ( INTEGER | TEXT | REAL | CHARACTER | REF i= ID | BOOLEAN )
            	int alt40 = 6;
            	switch ( input.LA(1) ) 
            	{
            	case INTEGER:
            		{
            	    alt40 = 1;
            	    }
            	    break;
            	case TEXT:
            		{
            	    alt40 = 2;
            	    }
            	    break;
            	case REAL:
            		{
            	    alt40 = 3;
            	    }
            	    break;
            	case CHARACTER:
            		{
            	    alt40 = 4;
            	    }
            	    break;
            	case REF:
            		{
            	    alt40 = 5;
            	    }
            	    break;
            	case BOOLEAN:
            		{
            	    alt40 = 6;
            	    }
            	    break;
            		default:
            		    if ( state.backtracking > 0 ) {state.failed = true; return ;}
            		    NoViableAltException nvae_d40s0 =
            		        new NoViableAltException("", 40, 0, input);

            		    throw nvae_d40s0;
            	}

            	switch (alt40) 
            	{
            	    case 1 :
            	        // C:\\work\\simsharp\\Src\\Ssc\\SimSharpGen.g:817:16: INTEGER
            	        {
            	        	Match(input,INTEGER,FOLLOW_INTEGER_in_type1826); if (state.failed) return ;

            	        }
            	        break;
            	    case 2 :
            	        // C:\\work\\simsharp\\Src\\Ssc\\SimSharpGen.g:818:5: TEXT
            	        {
            	        	Match(input,TEXT,FOLLOW_TEXT_in_type1833); if (state.failed) return ;

            	        }
            	        break;
            	    case 3 :
            	        // C:\\work\\simsharp\\Src\\Ssc\\SimSharpGen.g:819:5: REAL
            	        {
            	        	Match(input,REAL,FOLLOW_REAL_in_type1842); if (state.failed) return ;

            	        }
            	        break;
            	    case 4 :
            	        // C:\\work\\simsharp\\Src\\Ssc\\SimSharpGen.g:820:5: CHARACTER
            	        {
            	        	Match(input,CHARACTER,FOLLOW_CHARACTER_in_type1850); if (state.failed) return ;

            	        }
            	        break;
            	    case 5 :
            	        // C:\\work\\simsharp\\Src\\Ssc\\SimSharpGen.g:821:5: REF i= ID
            	        {
            	        	Match(input,REF,FOLLOW_REF_in_type1857); if (state.failed) return ;
            	        	i=(SimSharpTreeNode)Match(input,ID,FOLLOW_ID_in_type1861); if (state.failed) return ;

            	        }
            	        break;
            	    case 6 :
            	        // C:\\work\\simsharp\\Src\\Ssc\\SimSharpGen.g:822:5: BOOLEAN
            	        {
            	        	Match(input,BOOLEAN,FOLLOW_BOOLEAN_in_type1868); if (state.failed) return ;

            	        }
            	        break;

            	}


            	Match(input, Token.UP, null); if (state.failed) return ;

            }

        }
        catch (RecognitionException re) 
    	{
            ReportError(re);
            Recover(input,re);
        }
        finally 
    	{
        }
        return ;
    }
    // $ANTLR end "type"


    // $ANTLR start "refAssignment"
    // C:\\work\\simsharp\\Src\\Ssc\\SimSharpGen.g:827:1: refAssignment[bool nested] returns [TypeSymbol t] : ^(op= REFASSIGN d= lvalue (s= expression | r= refAssignment[true] ) ) ;
    public TypeSymbol refAssignment(bool nested) // throws RecognitionException [1]
    {   
        TypeSymbol t = default(TypeSymbol);

        SimSharpTreeNode op = null;
        SimSharpGen.lvalue_return d = default(SimSharpGen.lvalue_return);

        SimSharpGen.expression_return s = default(SimSharpGen.expression_return);

        TypeSymbol r = default(TypeSymbol);



        VariableSymbol temp = null;

        try 
    	{
            // C:\\work\\simsharp\\Src\\Ssc\\SimSharpGen.g:831:2: ( ^(op= REFASSIGN d= lvalue (s= expression | r= refAssignment[true] ) ) )
            // C:\\work\\simsharp\\Src\\Ssc\\SimSharpGen.g:831:4: ^(op= REFASSIGN d= lvalue (s= expression | r= refAssignment[true] ) )
            {
            	op=(SimSharpTreeNode)Match(input,REFASSIGN,FOLLOW_REFASSIGN_in_refAssignment1904); if (state.failed) return t;

            	Match(input, Token.DOWN, null); if (state.failed) return t;
            	PushFollow(FOLLOW_lvalue_in_refAssignment1910);
            	d = lvalue();
            	state.followingStackPointer--;
            	if (state.failed) return t;
            	// C:\\work\\simsharp\\Src\\Ssc\\SimSharpGen.g:833:3: (s= expression | r= refAssignment[true] )
            	int alt41 = 2;
            	alt41 = dfa41.Predict(input);
            	switch (alt41) 
            	{
            	    case 1 :
            	        // C:\\work\\simsharp\\Src\\Ssc\\SimSharpGen.g:834:4: s= expression
            	        {
            	        	PushFollow(FOLLOW_expression_in_refAssignment1921);
            	        	s = expression();
            	        	state.followingStackPointer--;
            	        	if (state.failed) return t;
            	        	if ( (state.backtracking==0) )
            	        	{

            	        	  			if (nested) 
            	        	  			{
            	        	  			  //cg.Dup();
            	        	  			  temp = cg.CreateTempVar("nestedAssign", ((s != null) ? s.t : default(TypeSymbol)));
            	        	  			  cg.Store(temp);
            	        	  			  cg.Load(temp);
            	        	  			  t =  ((s != null) ? s.t : default(TypeSymbol));
            	        	  			}
            	        	  			cg.RefAssign(((d != null) ? ((SimSharpTreeNode)d.Start) : null).Symbol, ((s != null) ? s.t : default(TypeSymbol)));	
            	        	  			if (nested) 
            	        	  			{
            	        	  			  cg.Load(temp);
            	        	  			}					 
            	        	  			
            	        	}

            	        }
            	        break;
            	    case 2 :
            	        // C:\\work\\simsharp\\Src\\Ssc\\SimSharpGen.g:851:4: r= refAssignment[true]
            	        {
            	        	PushFollow(FOLLOW_refAssignment_in_refAssignment1937);
            	        	r = refAssignment(true);
            	        	state.followingStackPointer--;
            	        	if (state.failed) return t;
            	        	if ( (state.backtracking==0) )
            	        	{

            	        	  			cg.RefAssign(((d != null) ? ((SimSharpTreeNode)d.Start) : null).Symbol, r);

            	        	  			
            	        	}

            	        }
            	        break;

            	}


            	Match(input, Token.UP, null); if (state.failed) return t;

            }

        }
        catch (RecognitionException re) 
    	{
            ReportError(re);
            Recover(input,re);
        }
        finally 
    	{
        }
        return t;
    }
    // $ANTLR end "refAssignment"


    // $ANTLR start "valueAssignment"
    // C:\\work\\simsharp\\Src\\Ssc\\SimSharpGen.g:860:1: valueAssignment : ^(op= VALASSIGN d= lvalue s= expression ) ;
    public void valueAssignment() // throws RecognitionException [1]
    {   
        SimSharpTreeNode op = null;
        SimSharpGen.lvalue_return d = default(SimSharpGen.lvalue_return);

        SimSharpGen.expression_return s = default(SimSharpGen.expression_return);


        try 
    	{
            // C:\\work\\simsharp\\Src\\Ssc\\SimSharpGen.g:861:2: ( ^(op= VALASSIGN d= lvalue s= expression ) )
            // C:\\work\\simsharp\\Src\\Ssc\\SimSharpGen.g:861:4: ^(op= VALASSIGN d= lvalue s= expression )
            {
            	op=(SimSharpTreeNode)Match(input,VALASSIGN,FOLLOW_VALASSIGN_in_valueAssignment1968); if (state.failed) return ;

            	if ( (state.backtracking==0) )
            	{
            	   valAssign = true; 
            	}

            	Match(input, Token.DOWN, null); if (state.failed) return ;
            	PushFollow(FOLLOW_lvalue_in_valueAssignment1978);
            	d = lvalue();
            	state.followingStackPointer--;
            	if (state.failed) return ;
            	if ( (state.backtracking==0) )
            	{

            	  		  
            	  		
            	}
            	PushFollow(FOLLOW_expression_in_valueAssignment1991);
            	s = expression();
            	state.followingStackPointer--;
            	if (state.failed) return ;

            	Match(input, Token.UP, null); if (state.failed) return ;
            	if ( (state.backtracking==0) )
            	{

            	  		if (((d != null) ? d.t : default(TypeSymbol)) == SymbolTable.Text || ((d != null) ? d.t : default(TypeSymbol)).GetDeRefType() == SymbolTable.Text)
            	  		{
            	  		  MethodSymbol m = ctx.Scope.ResolveType("Text").ResolveMethod("SetValue");
            	  		  cg.CallMethod(m);
            	  		}
            	  		else cg.ValAssign(((d != null) ? ((SimSharpTreeNode)d.Start) : null).Symbol, ((s != null) ? s.t : default(TypeSymbol)));
            	  		
            	  		valAssign = false;
            	  		
            	}

            }

        }
        catch (RecognitionException re) 
    	{
            ReportError(re);
            Recover(input,re);
        }
        finally 
    	{
        }
        return ;
    }
    // $ANTLR end "valueAssignment"

    public class lvalue_return : TreeRuleReturnScope
    {
        public TypeSymbol t;
    };

    // $ANTLR start "lvalue"
    // C:\\work\\simsharp\\Src\\Ssc\\SimSharpGen.g:880:1: lvalue returns [TypeSymbol t] : ( ( ID ActualParameters )=> arrayAssign | assignableId | remoteAssign );
    public SimSharpGen.lvalue_return lvalue() // throws RecognitionException [1]
    {   
        SimSharpGen.lvalue_return retval = new SimSharpGen.lvalue_return();
        retval.Start = input.LT(1);

        try 
    	{
            // C:\\work\\simsharp\\Src\\Ssc\\SimSharpGen.g:881:2: ( ( ID ActualParameters )=> arrayAssign | assignableId | remoteAssign )
            int alt42 = 3;
            int LA42_0 = input.LA(1);

            if ( (LA42_0 == ID) )
            {
                int LA42_1 = input.LA(2);

                if ( (synpred1_SimSharpGen()) )
                {
                    alt42 = 1;
                }
                else if ( (true) )
                {
                    alt42 = 2;
                }
                else 
                {
                    if ( state.backtracking > 0 ) {state.failed = true; return retval;}
                    NoViableAltException nvae_d42s1 =
                        new NoViableAltException("", 42, 1, input);

                    throw nvae_d42s1;
                }
            }
            else if ( (LA42_0 == RemoteAssign) )
            {
                alt42 = 3;
            }
            else 
            {
                if ( state.backtracking > 0 ) {state.failed = true; return retval;}
                NoViableAltException nvae_d42s0 =
                    new NoViableAltException("", 42, 0, input);

                throw nvae_d42s0;
            }
            switch (alt42) 
            {
                case 1 :
                    // C:\\work\\simsharp\\Src\\Ssc\\SimSharpGen.g:881:4: ( ID ActualParameters )=> arrayAssign
                    {
                    	PushFollow(FOLLOW_arrayAssign_in_lvalue2025);
                    	arrayAssign();
                    	state.followingStackPointer--;
                    	if (state.failed) return retval;
                    	if ( (state.backtracking==0) )
                    	{
                    	   retval.t =  ((SimSharpTreeNode)retval.Start).ExprType; 
                    	}

                    }
                    break;
                case 2 :
                    // C:\\work\\simsharp\\Src\\Ssc\\SimSharpGen.g:882:4: assignableId
                    {
                    	PushFollow(FOLLOW_assignableId_in_lvalue2032);
                    	assignableId();
                    	state.followingStackPointer--;
                    	if (state.failed) return retval;
                    	if ( (state.backtracking==0) )
                    	{
                    	   retval.t =  ((SimSharpTreeNode)retval.Start).ExprType; 
                    	}

                    }
                    break;
                case 3 :
                    // C:\\work\\simsharp\\Src\\Ssc\\SimSharpGen.g:883:4: remoteAssign
                    {
                    	PushFollow(FOLLOW_remoteAssign_in_lvalue2039);
                    	remoteAssign();
                    	state.followingStackPointer--;
                    	if (state.failed) return retval;
                    	if ( (state.backtracking==0) )
                    	{
                    	   retval.t =  ((SimSharpTreeNode)retval.Start).ExprType; 
                    	}

                    }
                    break;

            }
        }
        catch (RecognitionException re) 
    	{
            ReportError(re);
            Recover(input,re);
        }
        finally 
    	{
        }
        return retval;
    }
    // $ANTLR end "lvalue"


    // $ANTLR start "arrayAssign"
    // C:\\work\\simsharp\\Src\\Ssc\\SimSharpGen.g:886:1: arrayAssign : i= ID actualParams[null] ;
    public void arrayAssign() // throws RecognitionException [1]
    {   
        SimSharpTreeNode i = null;


        Symbol array = null;

        try 
    	{
            // C:\\work\\simsharp\\Src\\Ssc\\SimSharpGen.g:890:2: (i= ID actualParams[null] )
            // C:\\work\\simsharp\\Src\\Ssc\\SimSharpGen.g:890:4: i= ID actualParams[null]
            {
            	i=(SimSharpTreeNode)Match(input,ID,FOLLOW_ID_in_arrayAssign2060); if (state.failed) return ;
            	if ( (state.backtracking==0) )
            	{

            	  	array = ctx.Scope.Resolve(i.Text);
            	  	
            	  	cg.LoadThisOrInspect(array);
            	  	cg.Load(array);
            	  	
            	}
            	PushFollow(FOLLOW_actualParams_in_arrayAssign2067);
            	actualParams(null);
            	state.followingStackPointer--;
            	if (state.failed) return ;
            	if ( (state.backtracking==0) )
            	{
            	  	
            	  	if (valAssign && array.Type.ElementType == SymbolTable.Text) cg.LoadAsObject(array.Type);
            	  	
            	  	i.Symbol = array.Type;   //setting symbol to ararys TypeSymbol in order to flag element assignment
            	  	i.ExprType = array.Type.ElementType;
            	  	
            	}

            }

        }
        catch (RecognitionException re) 
    	{
            ReportError(re);
            Recover(input,re);
        }
        finally 
    	{
        }
        return ;
    }
    // $ANTLR end "arrayAssign"

    public class assignableId_return : TreeRuleReturnScope
    {
    };

    // $ANTLR start "assignableId"
    // C:\\work\\simsharp\\Src\\Ssc\\SimSharpGen.g:906:1: assignableId : i= ID ;
    public SimSharpGen.assignableId_return assignableId() // throws RecognitionException [1]
    {   
        SimSharpGen.assignableId_return retval = new SimSharpGen.assignableId_return();
        retval.Start = input.LT(1);

        SimSharpTreeNode i = null;

        try 
    	{
            // C:\\work\\simsharp\\Src\\Ssc\\SimSharpGen.g:907:2: (i= ID )
            // C:\\work\\simsharp\\Src\\Ssc\\SimSharpGen.g:907:4: i= ID
            {
            	i=(SimSharpTreeNode)Match(input,ID,FOLLOW_ID_in_assignableId2086); if (state.failed) return retval;
            	if ( (state.backtracking==0) )
            	{

            	  	    Symbol id = ctx.Scope.Resolve(i.Text);
            	  	    if (id != null)
            	  	    {
            	  	      if (id is MethodSymbol)
            	  	      {
            	  	        if (id == ctx.CurrentMethod)
            	  	        {
            	  	          id = ctx.Scope.ResolveVariable("_retVal");
            	  	        }
            	  	        else errMan.ReportError("CodeGen", i.Line, i.CharPositionInLine, "Illegal procedure assignment '" + ((i != null) ? i.Text : null) + "'");
            	  	      }
            	  	      
            	  	      if (!(id is VariableSymbol || id is FieldSymbol || id is ArgumentSymbol)) 
            	  	         throw new NotImplementedException("We only support variabl,field or argument assignment for now '" + ((i != null) ? i.Text : null) + "'");
            	  	      
            	  	      if (id is FieldSymbol) 
            	  	      {
            	  	        if (!ctx.Remote) cg.LoadThisOrInspect(id);
            	  	      }
            	  	      
            	  	      
            	  	      ArgumentSymbol arg = id as ArgumentSymbol;
            	  	      if (arg != null && arg.NameParam) 
            	  	        cg.Load(id); 
            	  	      
            	  	      else if (valAssign && id.Type == SymbolTable.Text)
            	  	        cg.LoadAsObject(id);
            	  	      
            	  	      
            	  	      i.Symbol = id;
            	  	      i.ExprType = id.Type;
            	  	    }
            	  	    else errMan.ReportError("CodeGen", i.Line, i.CharPositionInLine, "Unrecognized identifier '" + ((i != null) ? i.Text : null) + "'");
            	  	  
            	}

            }

        }
        catch (RecognitionException re) 
    	{
            ReportError(re);
            Recover(input,re);
        }
        finally 
    	{
        }
        return retval;
    }
    // $ANTLR end "assignableId"


    // $ANTLR start "refExpression"
    // C:\\work\\simsharp\\Src\\Ssc\\SimSharpGen.g:945:1: refExpression returns [TypeSymbol t] : e= expression ;
    public TypeSymbol refExpression() // throws RecognitionException [1]
    {   
        TypeSymbol t = default(TypeSymbol);

        SimSharpGen.expression_return e = default(SimSharpGen.expression_return);



        bool oldValue = false;

        try 
    	{
            // C:\\work\\simsharp\\Src\\Ssc\\SimSharpGen.g:949:2: (e= expression )
            // C:\\work\\simsharp\\Src\\Ssc\\SimSharpGen.g:949:4: e= expression
            {
            	if ( (state.backtracking==0) )
            	{

            	  	    oldValue = this.loadAsObject;
            	  	    this.loadAsObject = true;
            	  	  
            	}
            	PushFollow(FOLLOW_expression_in_refExpression2118);
            	e = expression();
            	state.followingStackPointer--;
            	if (state.failed) return t;
            	if ( (state.backtracking==0) )
            	{

            	  	    t =  ((e != null) ? e.t : default(TypeSymbol));
            	  	    this.loadAsObject = oldValue;
            	  	    
            	  	    if (!(((e != null) ? e.t : default(TypeSymbol)).SystemType.IsClass || ((e != null) ? e.t : default(TypeSymbol)) == SymbolTable.Text))
            	  	      errMan.ReportError("CodeGen", ((e != null) ? ((SimSharpTreeNode)e.Start) : null).Line, ((e != null) ? ((SimSharpTreeNode)e.Start) : null).CharPositionInLine, "Expression must be of object or Text type. Found '" + ((e != null) ? e.t : default(TypeSymbol)).Name + "'");
            	  	  
            	}

            }

        }
        catch (RecognitionException re) 
    	{
            ReportError(re);
            Recover(input,re);
        }
        finally 
    	{
        }
        return t;
    }
    // $ANTLR end "refExpression"


    // $ANTLR start "objectExpression"
    // C:\\work\\simsharp\\Src\\Ssc\\SimSharpGen.g:963:1: objectExpression returns [TypeSymbol t] : e= expression ;
    public TypeSymbol objectExpression() // throws RecognitionException [1]
    {   
        TypeSymbol t = default(TypeSymbol);

        SimSharpGen.expression_return e = default(SimSharpGen.expression_return);



        bool oldValue = false;

        try 
    	{
            // C:\\work\\simsharp\\Src\\Ssc\\SimSharpGen.g:967:2: (e= expression )
            // C:\\work\\simsharp\\Src\\Ssc\\SimSharpGen.g:967:4: e= expression
            {
            	if ( (state.backtracking==0) )
            	{

            	  	    oldValue = this.loadAsObject;
            	  	    this.loadAsObject = true;
            	  	  
            	}
            	PushFollow(FOLLOW_expression_in_objectExpression2150);
            	e = expression();
            	state.followingStackPointer--;
            	if (state.failed) return t;
            	if ( (state.backtracking==0) )
            	{

            	  	    t =  ((e != null) ? e.t : default(TypeSymbol));
            	  	    this.loadAsObject = oldValue;
            	  	    
            	  	    if (! (((e != null) ? e.t : default(TypeSymbol))).SystemType.IsClass)
            	  	      errMan.ReportError("CodeGen", ((e != null) ? ((SimSharpTreeNode)e.Start) : null).Line, ((e != null) ? ((SimSharpTreeNode)e.Start) : null).CharPositionInLine, "Expression must be of object type. Found '" + ((e != null) ? e.t : default(TypeSymbol)).Name + "'");
            	  	  
            	}

            }

        }
        catch (RecognitionException re) 
    	{
            ReportError(re);
            Recover(input,re);
        }
        finally 
    	{
        }
        return t;
    }
    // $ANTLR end "objectExpression"


    // $ANTLR start "boolExpression"
    // C:\\work\\simsharp\\Src\\Ssc\\SimSharpGen.g:981:1: boolExpression : e= expression ;
    public void boolExpression() // throws RecognitionException [1]
    {   
        SimSharpGen.expression_return e = default(SimSharpGen.expression_return);


        try 
    	{
            // C:\\work\\simsharp\\Src\\Ssc\\SimSharpGen.g:982:2: (e= expression )
            // C:\\work\\simsharp\\Src\\Ssc\\SimSharpGen.g:982:4: e= expression
            {
            	PushFollow(FOLLOW_expression_in_boolExpression2169);
            	e = expression();
            	state.followingStackPointer--;
            	if (state.failed) return ;
            	if ( (state.backtracking==0) )
            	{

            	  	  TypeSymbol t = ((e != null) ? e.t : default(TypeSymbol));
            	  	  if (t != SymbolTable.Boolean) errMan.ReportError("CodeGen", ((e != null) ? ((SimSharpTreeNode)e.Start) : null).Line, ((e != null) ? ((SimSharpTreeNode)e.Start) : null).CharPositionInLine, "Expression must be of type Boolean. Found '" + t.Name + "'");
            	  	  
            	}

            }

        }
        catch (RecognitionException re) 
    	{
            ReportError(re);
            Recover(input,re);
        }
        finally 
    	{
        }
        return ;
    }
    // $ANTLR end "boolExpression"

    public class classId_return : TreeRuleReturnScope
    {
        public TypeSymbol type;
    };

    // $ANTLR start "classId"
    // C:\\work\\simsharp\\Src\\Ssc\\SimSharpGen.g:989:1: classId returns [TypeSymbol type] : i= ID ;
    public SimSharpGen.classId_return classId() // throws RecognitionException [1]
    {   
        SimSharpGen.classId_return retval = new SimSharpGen.classId_return();
        retval.Start = input.LT(1);

        SimSharpTreeNode i = null;

        try 
    	{
            // C:\\work\\simsharp\\Src\\Ssc\\SimSharpGen.g:990:2: (i= ID )
            // C:\\work\\simsharp\\Src\\Ssc\\SimSharpGen.g:990:4: i= ID
            {
            	i=(SimSharpTreeNode)Match(input,ID,FOLLOW_ID_in_classId2194); if (state.failed) return retval;
            	if ( (state.backtracking==0) )
            	{

            	  	  TypeSymbol t = ctx.Scope.ResolveType(((i != null) ? i.Text : null));
            	  	  if (t == null) errMan.ReportError("CodeGen", i.Line, i.CharPositionInLine, "Class identifier expected. Found '" + ((i != null) ? i.Text : null) + "'");
            	  	  retval.type =  t;
            	  	  
            	}

            }

        }
        catch (RecognitionException re) 
    	{
            ReportError(re);
            Recover(input,re);
        }
        finally 
    	{
        }
        return retval;
    }
    // $ANTLR end "classId"

    public class expression_return : TreeRuleReturnScope
    {
        public TypeSymbol t;
    };

    // $ANTLR start "expression"
    // C:\\work\\simsharp\\Src\\Ssc\\SimSharpGen.g:998:1: expression returns [TypeSymbol t] : ( primary | ^( CONCAT x= expression y= expression ) | ^( EQ x= expression y= expression ) | ^( NE x= expression y= expression ) | ^( GT x= expression y= expression ) | ^( LT x= expression y= expression ) | ^( GE x= expression y= expression ) | ^( LE x= expression y= expression ) | ^( MINUS x= expression y= expression ) | ^( PLUS x= expression y= expression ) | ^( TIMES x= expression y= expression ) | ^( INTDIV expression expression ) | ^( EXP x= expression y= expression ) | ^( NOT expression ) | ^( Unary MINUS x= expression ) | remote | objectGenerator | ^( REFNEQ expression expression ) | ^( REFEQ expression expression ) | ^( IN objectExpression c= classId ) | ^( IS objectExpression c= classId ) | ^( AND boolExpression boolExpression ) | ^( OR boolExpression boolExpression ) | ^( EQV boolExpression boolExpression ) | ^( IMP boolExpression boolExpression ) | andThen | orElse | ^( QUA o= objectExpression c= classId ) | ^( THIS c= classId ) );
    public SimSharpGen.expression_return expression() // throws RecognitionException [1]
    {   
        SimSharpGen.expression_return retval = new SimSharpGen.expression_return();
        retval.Start = input.LT(1);

        SimSharpGen.expression_return x = default(SimSharpGen.expression_return);

        SimSharpGen.expression_return y = default(SimSharpGen.expression_return);

        SimSharpGen.classId_return c = default(SimSharpGen.classId_return);

        TypeSymbol o = default(TypeSymbol);

        SimSharpGen.primary_return primary4 = default(SimSharpGen.primary_return);

        SimSharpGen.remote_return remote5 = default(SimSharpGen.remote_return);

        SimSharpGen.objectGenerator_return objectGenerator6 = default(SimSharpGen.objectGenerator_return);


        try 
    	{
            // C:\\work\\simsharp\\Src\\Ssc\\SimSharpGen.g:1000:2: ( primary | ^( CONCAT x= expression y= expression ) | ^( EQ x= expression y= expression ) | ^( NE x= expression y= expression ) | ^( GT x= expression y= expression ) | ^( LT x= expression y= expression ) | ^( GE x= expression y= expression ) | ^( LE x= expression y= expression ) | ^( MINUS x= expression y= expression ) | ^( PLUS x= expression y= expression ) | ^( TIMES x= expression y= expression ) | ^( INTDIV expression expression ) | ^( EXP x= expression y= expression ) | ^( NOT expression ) | ^( Unary MINUS x= expression ) | remote | objectGenerator | ^( REFNEQ expression expression ) | ^( REFEQ expression expression ) | ^( IN objectExpression c= classId ) | ^( IS objectExpression c= classId ) | ^( AND boolExpression boolExpression ) | ^( OR boolExpression boolExpression ) | ^( EQV boolExpression boolExpression ) | ^( IMP boolExpression boolExpression ) | andThen | orElse | ^( QUA o= objectExpression c= classId ) | ^( THIS c= classId ) )
            int alt43 = 29;
            alt43 = dfa43.Predict(input);
            switch (alt43) 
            {
                case 1 :
                    // C:\\work\\simsharp\\Src\\Ssc\\SimSharpGen.g:1000:4: primary
                    {
                    	PushFollow(FOLLOW_primary_in_expression2216);
                    	primary4 = primary();
                    	state.followingStackPointer--;
                    	if (state.failed) return retval;
                    	if ( (state.backtracking==0) )
                    	{
                    	   retval.t =  ((primary4 != null) ? ((SimSharpTreeNode)primary4.Start) : null).ExprType; 
                    	}

                    }
                    break;
                case 2 :
                    // C:\\work\\simsharp\\Src\\Ssc\\SimSharpGen.g:1001:4: ^( CONCAT x= expression y= expression )
                    {
                    	Match(input,CONCAT,FOLLOW_CONCAT_in_expression2224); if (state.failed) return retval;

                    	Match(input, Token.DOWN, null); if (state.failed) return retval;
                    	PushFollow(FOLLOW_expression_in_expression2228);
                    	x = expression();
                    	state.followingStackPointer--;
                    	if (state.failed) return retval;
                    	PushFollow(FOLLOW_expression_in_expression2232);
                    	y = expression();
                    	state.followingStackPointer--;
                    	if (state.failed) return retval;

                    	Match(input, Token.UP, null); if (state.failed) return retval;
                    	if ( (state.backtracking==0) )
                    	{
                    	   retval.t =  SymbolTable.Text; cg.ExprConcatText(); 
                    	}

                    }
                    break;
                case 3 :
                    // C:\\work\\simsharp\\Src\\Ssc\\SimSharpGen.g:1002:4: ^( EQ x= expression y= expression )
                    {
                    	Match(input,EQ,FOLLOW_EQ_in_expression2241); if (state.failed) return retval;

                    	Match(input, Token.DOWN, null); if (state.failed) return retval;
                    	PushFollow(FOLLOW_expression_in_expression2245);
                    	x = expression();
                    	state.followingStackPointer--;
                    	if (state.failed) return retval;
                    	PushFollow(FOLLOW_expression_in_expression2249);
                    	y = expression();
                    	state.followingStackPointer--;
                    	if (state.failed) return retval;

                    	Match(input, Token.UP, null); if (state.failed) return retval;
                    	if ( (state.backtracking==0) )
                    	{
                    	   retval.t =  SymbolTable.Boolean; cg.ValueRelation(((x != null) ? x.t : default(TypeSymbol)), ((y != null) ? y.t : default(TypeSymbol))); cg.ExprEq(); 
                    	}

                    }
                    break;
                case 4 :
                    // C:\\work\\simsharp\\Src\\Ssc\\SimSharpGen.g:1003:4: ^( NE x= expression y= expression )
                    {
                    	Match(input,NE,FOLLOW_NE_in_expression2258); if (state.failed) return retval;

                    	Match(input, Token.DOWN, null); if (state.failed) return retval;
                    	PushFollow(FOLLOW_expression_in_expression2262);
                    	x = expression();
                    	state.followingStackPointer--;
                    	if (state.failed) return retval;
                    	PushFollow(FOLLOW_expression_in_expression2266);
                    	y = expression();
                    	state.followingStackPointer--;
                    	if (state.failed) return retval;

                    	Match(input, Token.UP, null); if (state.failed) return retval;
                    	if ( (state.backtracking==0) )
                    	{
                    	   retval.t =  SymbolTable.Boolean; cg.ValueRelation(((x != null) ? x.t : default(TypeSymbol)), ((y != null) ? y.t : default(TypeSymbol))); cg.ExprNe(); 
                    	}

                    }
                    break;
                case 5 :
                    // C:\\work\\simsharp\\Src\\Ssc\\SimSharpGen.g:1004:4: ^( GT x= expression y= expression )
                    {
                    	Match(input,GT,FOLLOW_GT_in_expression2275); if (state.failed) return retval;

                    	Match(input, Token.DOWN, null); if (state.failed) return retval;
                    	PushFollow(FOLLOW_expression_in_expression2279);
                    	x = expression();
                    	state.followingStackPointer--;
                    	if (state.failed) return retval;
                    	PushFollow(FOLLOW_expression_in_expression2283);
                    	y = expression();
                    	state.followingStackPointer--;
                    	if (state.failed) return retval;

                    	Match(input, Token.UP, null); if (state.failed) return retval;
                    	if ( (state.backtracking==0) )
                    	{
                    	   retval.t =  SymbolTable.Boolean; cg.ValueRelation(((x != null) ? x.t : default(TypeSymbol)), ((y != null) ? y.t : default(TypeSymbol))); cg.ExprGt(); 
                    	}

                    }
                    break;
                case 6 :
                    // C:\\work\\simsharp\\Src\\Ssc\\SimSharpGen.g:1005:4: ^( LT x= expression y= expression )
                    {
                    	Match(input,LT,FOLLOW_LT_in_expression2292); if (state.failed) return retval;

                    	Match(input, Token.DOWN, null); if (state.failed) return retval;
                    	PushFollow(FOLLOW_expression_in_expression2296);
                    	x = expression();
                    	state.followingStackPointer--;
                    	if (state.failed) return retval;
                    	PushFollow(FOLLOW_expression_in_expression2300);
                    	y = expression();
                    	state.followingStackPointer--;
                    	if (state.failed) return retval;

                    	Match(input, Token.UP, null); if (state.failed) return retval;
                    	if ( (state.backtracking==0) )
                    	{
                    	   retval.t =  SymbolTable.Boolean; cg.ValueRelation(((x != null) ? x.t : default(TypeSymbol)), ((y != null) ? y.t : default(TypeSymbol))); cg.ExprLt(); 
                    	}

                    }
                    break;
                case 7 :
                    // C:\\work\\simsharp\\Src\\Ssc\\SimSharpGen.g:1006:4: ^( GE x= expression y= expression )
                    {
                    	Match(input,GE,FOLLOW_GE_in_expression2309); if (state.failed) return retval;

                    	Match(input, Token.DOWN, null); if (state.failed) return retval;
                    	PushFollow(FOLLOW_expression_in_expression2313);
                    	x = expression();
                    	state.followingStackPointer--;
                    	if (state.failed) return retval;
                    	PushFollow(FOLLOW_expression_in_expression2317);
                    	y = expression();
                    	state.followingStackPointer--;
                    	if (state.failed) return retval;

                    	Match(input, Token.UP, null); if (state.failed) return retval;
                    	if ( (state.backtracking==0) )
                    	{
                    	   retval.t =  SymbolTable.Boolean; cg.ValueRelation(((x != null) ? x.t : default(TypeSymbol)), ((y != null) ? y.t : default(TypeSymbol))); cg.ExprGe(); 
                    	}

                    }
                    break;
                case 8 :
                    // C:\\work\\simsharp\\Src\\Ssc\\SimSharpGen.g:1007:4: ^( LE x= expression y= expression )
                    {
                    	Match(input,LE,FOLLOW_LE_in_expression2326); if (state.failed) return retval;

                    	Match(input, Token.DOWN, null); if (state.failed) return retval;
                    	PushFollow(FOLLOW_expression_in_expression2330);
                    	x = expression();
                    	state.followingStackPointer--;
                    	if (state.failed) return retval;
                    	PushFollow(FOLLOW_expression_in_expression2334);
                    	y = expression();
                    	state.followingStackPointer--;
                    	if (state.failed) return retval;

                    	Match(input, Token.UP, null); if (state.failed) return retval;
                    	if ( (state.backtracking==0) )
                    	{
                    	   retval.t =  SymbolTable.Boolean; cg.ValueRelation(((x != null) ? x.t : default(TypeSymbol)), ((y != null) ? y.t : default(TypeSymbol))); cg.ExprLe(); 
                    	}

                    }
                    break;
                case 9 :
                    // C:\\work\\simsharp\\Src\\Ssc\\SimSharpGen.g:1008:4: ^( MINUS x= expression y= expression )
                    {
                    	Match(input,MINUS,FOLLOW_MINUS_in_expression2343); if (state.failed) return retval;

                    	Match(input, Token.DOWN, null); if (state.failed) return retval;
                    	PushFollow(FOLLOW_expression_in_expression2347);
                    	x = expression();
                    	state.followingStackPointer--;
                    	if (state.failed) return retval;
                    	PushFollow(FOLLOW_expression_in_expression2351);
                    	y = expression();
                    	state.followingStackPointer--;
                    	if (state.failed) return retval;

                    	Match(input, Token.UP, null); if (state.failed) return retval;
                    	if ( (state.backtracking==0) )
                    	{
                    	   retval.t =  ((x != null) ? x.t : default(TypeSymbol)); cg.ExprMinus(); 
                    	}

                    }
                    break;
                case 10 :
                    // C:\\work\\simsharp\\Src\\Ssc\\SimSharpGen.g:1009:4: ^( PLUS x= expression y= expression )
                    {
                    	Match(input,PLUS,FOLLOW_PLUS_in_expression2360); if (state.failed) return retval;

                    	Match(input, Token.DOWN, null); if (state.failed) return retval;
                    	PushFollow(FOLLOW_expression_in_expression2364);
                    	x = expression();
                    	state.followingStackPointer--;
                    	if (state.failed) return retval;
                    	PushFollow(FOLLOW_expression_in_expression2368);
                    	y = expression();
                    	state.followingStackPointer--;
                    	if (state.failed) return retval;

                    	Match(input, Token.UP, null); if (state.failed) return retval;
                    	if ( (state.backtracking==0) )
                    	{
                    	   retval.t =  ((x != null) ? x.t : default(TypeSymbol)); cg.ExprPlus(); 
                    	}

                    }
                    break;
                case 11 :
                    // C:\\work\\simsharp\\Src\\Ssc\\SimSharpGen.g:1010:4: ^( TIMES x= expression y= expression )
                    {
                    	Match(input,TIMES,FOLLOW_TIMES_in_expression2377); if (state.failed) return retval;

                    	Match(input, Token.DOWN, null); if (state.failed) return retval;
                    	PushFollow(FOLLOW_expression_in_expression2381);
                    	x = expression();
                    	state.followingStackPointer--;
                    	if (state.failed) return retval;
                    	PushFollow(FOLLOW_expression_in_expression2385);
                    	y = expression();
                    	state.followingStackPointer--;
                    	if (state.failed) return retval;

                    	Match(input, Token.UP, null); if (state.failed) return retval;
                    	if ( (state.backtracking==0) )
                    	{
                    	   retval.t =  ((x != null) ? x.t : default(TypeSymbol)); cg.ExprTimes(); 
                    	}

                    }
                    break;
                case 12 :
                    // C:\\work\\simsharp\\Src\\Ssc\\SimSharpGen.g:1011:5: ^( INTDIV expression expression )
                    {
                    	Match(input,INTDIV,FOLLOW_INTDIV_in_expression2395); if (state.failed) return retval;

                    	Match(input, Token.DOWN, null); if (state.failed) return retval;
                    	PushFollow(FOLLOW_expression_in_expression2397);
                    	expression();
                    	state.followingStackPointer--;
                    	if (state.failed) return retval;
                    	PushFollow(FOLLOW_expression_in_expression2399);
                    	expression();
                    	state.followingStackPointer--;
                    	if (state.failed) return retval;

                    	Match(input, Token.UP, null); if (state.failed) return retval;
                    	if ( (state.backtracking==0) )
                    	{
                    	   retval.t =  ((x != null) ? x.t : default(TypeSymbol)); cg.ExprIntDiv(); 
                    	}

                    }
                    break;
                case 13 :
                    // C:\\work\\simsharp\\Src\\Ssc\\SimSharpGen.g:1012:5: ^( EXP x= expression y= expression )
                    {
                    	Match(input,EXP,FOLLOW_EXP_in_expression2409); if (state.failed) return retval;

                    	Match(input, Token.DOWN, null); if (state.failed) return retval;
                    	PushFollow(FOLLOW_expression_in_expression2413);
                    	x = expression();
                    	state.followingStackPointer--;
                    	if (state.failed) return retval;
                    	PushFollow(FOLLOW_expression_in_expression2417);
                    	y = expression();
                    	state.followingStackPointer--;
                    	if (state.failed) return retval;

                    	Match(input, Token.UP, null); if (state.failed) return retval;
                    	if ( (state.backtracking==0) )
                    	{
                    	   retval.t =  ((x != null) ? x.t : default(TypeSymbol)); cg.ExprExp(); 
                    	}

                    }
                    break;
                case 14 :
                    // C:\\work\\simsharp\\Src\\Ssc\\SimSharpGen.g:1013:5: ^( NOT expression )
                    {
                    	Match(input,NOT,FOLLOW_NOT_in_expression2427); if (state.failed) return retval;

                    	Match(input, Token.DOWN, null); if (state.failed) return retval;
                    	PushFollow(FOLLOW_expression_in_expression2429);
                    	expression();
                    	state.followingStackPointer--;
                    	if (state.failed) return retval;

                    	Match(input, Token.UP, null); if (state.failed) return retval;
                    	if ( (state.backtracking==0) )
                    	{
                    	   retval.t =  SymbolTable.Boolean; cg.ExprNot(); 
                    	}

                    }
                    break;
                case 15 :
                    // C:\\work\\simsharp\\Src\\Ssc\\SimSharpGen.g:1014:5: ^( Unary MINUS x= expression )
                    {
                    	Match(input,Unary,FOLLOW_Unary_in_expression2439); if (state.failed) return retval;

                    	Match(input, Token.DOWN, null); if (state.failed) return retval;
                    	Match(input,MINUS,FOLLOW_MINUS_in_expression2441); if (state.failed) return retval;
                    	PushFollow(FOLLOW_expression_in_expression2445);
                    	x = expression();
                    	state.followingStackPointer--;
                    	if (state.failed) return retval;

                    	Match(input, Token.UP, null); if (state.failed) return retval;
                    	if ( (state.backtracking==0) )
                    	{
                    	   retval.t =  ((x != null) ? x.t : default(TypeSymbol)); cg.ExprNeg(); 
                    	}

                    }
                    break;
                case 16 :
                    // C:\\work\\simsharp\\Src\\Ssc\\SimSharpGen.g:1015:5: remote
                    {
                    	PushFollow(FOLLOW_remote_in_expression2455);
                    	remote5 = remote();
                    	state.followingStackPointer--;
                    	if (state.failed) return retval;
                    	if ( (state.backtracking==0) )
                    	{
                    	   retval.t =  ((remote5 != null) ? ((SimSharpTreeNode)remote5.Start) : null).ExprType; 
                    	}

                    }
                    break;
                case 17 :
                    // C:\\work\\simsharp\\Src\\Ssc\\SimSharpGen.g:1016:5: objectGenerator
                    {
                    	PushFollow(FOLLOW_objectGenerator_in_expression2463);
                    	objectGenerator6 = objectGenerator();
                    	state.followingStackPointer--;
                    	if (state.failed) return retval;
                    	if ( (state.backtracking==0) )
                    	{
                    	   retval.t =  ((objectGenerator6 != null) ? ((SimSharpTreeNode)objectGenerator6.Start) : null).ExprType; 
                    	}

                    }
                    break;
                case 18 :
                    // C:\\work\\simsharp\\Src\\Ssc\\SimSharpGen.g:1017:4: ^( REFNEQ expression expression )
                    {
                    	Match(input,REFNEQ,FOLLOW_REFNEQ_in_expression2471); if (state.failed) return retval;

                    	Match(input, Token.DOWN, null); if (state.failed) return retval;
                    	PushFollow(FOLLOW_expression_in_expression2473);
                    	expression();
                    	state.followingStackPointer--;
                    	if (state.failed) return retval;
                    	PushFollow(FOLLOW_expression_in_expression2475);
                    	expression();
                    	state.followingStackPointer--;
                    	if (state.failed) return retval;

                    	Match(input, Token.UP, null); if (state.failed) return retval;
                    	if ( (state.backtracking==0) )
                    	{
                    	   retval.t =  SymbolTable.Boolean; cg.ExprNe(); 
                    	}

                    }
                    break;
                case 19 :
                    // C:\\work\\simsharp\\Src\\Ssc\\SimSharpGen.g:1018:4: ^( REFEQ expression expression )
                    {
                    	Match(input,REFEQ,FOLLOW_REFEQ_in_expression2486); if (state.failed) return retval;

                    	Match(input, Token.DOWN, null); if (state.failed) return retval;
                    	PushFollow(FOLLOW_expression_in_expression2488);
                    	expression();
                    	state.followingStackPointer--;
                    	if (state.failed) return retval;
                    	PushFollow(FOLLOW_expression_in_expression2490);
                    	expression();
                    	state.followingStackPointer--;
                    	if (state.failed) return retval;

                    	Match(input, Token.UP, null); if (state.failed) return retval;
                    	if ( (state.backtracking==0) )
                    	{
                    	   retval.t =  SymbolTable.Boolean; cg.ExprEq(); 
                    	}

                    }
                    break;
                case 20 :
                    // C:\\work\\simsharp\\Src\\Ssc\\SimSharpGen.g:1019:4: ^( IN objectExpression c= classId )
                    {
                    	Match(input,IN,FOLLOW_IN_in_expression2501); if (state.failed) return retval;

                    	Match(input, Token.DOWN, null); if (state.failed) return retval;
                    	PushFollow(FOLLOW_objectExpression_in_expression2503);
                    	objectExpression();
                    	state.followingStackPointer--;
                    	if (state.failed) return retval;
                    	PushFollow(FOLLOW_classId_in_expression2507);
                    	c = classId();
                    	state.followingStackPointer--;
                    	if (state.failed) return retval;

                    	Match(input, Token.UP, null); if (state.failed) return retval;
                    	if ( (state.backtracking==0) )
                    	{
                    	   retval.t =  SymbolTable.Boolean; cg.ExprIn(((c != null) ? c.type : default(TypeSymbol))); 
                    	}

                    }
                    break;
                case 21 :
                    // C:\\work\\simsharp\\Src\\Ssc\\SimSharpGen.g:1020:4: ^( IS objectExpression c= classId )
                    {
                    	Match(input,IS,FOLLOW_IS_in_expression2516); if (state.failed) return retval;

                    	Match(input, Token.DOWN, null); if (state.failed) return retval;
                    	PushFollow(FOLLOW_objectExpression_in_expression2518);
                    	objectExpression();
                    	state.followingStackPointer--;
                    	if (state.failed) return retval;
                    	if ( (state.backtracking==0) )
                    	{
                    	   cg.LoadObjectType(); 
                    	}
                    	PushFollow(FOLLOW_classId_in_expression2525);
                    	c = classId();
                    	state.followingStackPointer--;
                    	if (state.failed) return retval;

                    	Match(input, Token.UP, null); if (state.failed) return retval;
                    	if ( (state.backtracking==0) )
                    	{
                    	   retval.t =  SymbolTable.Boolean; cg.ExprIs(((c != null) ? c.type : default(TypeSymbol))); 
                    	}

                    }
                    break;
                case 22 :
                    // C:\\work\\simsharp\\Src\\Ssc\\SimSharpGen.g:1021:4: ^( AND boolExpression boolExpression )
                    {
                    	Match(input,AND,FOLLOW_AND_in_expression2534); if (state.failed) return retval;

                    	Match(input, Token.DOWN, null); if (state.failed) return retval;
                    	PushFollow(FOLLOW_boolExpression_in_expression2536);
                    	boolExpression();
                    	state.followingStackPointer--;
                    	if (state.failed) return retval;
                    	PushFollow(FOLLOW_boolExpression_in_expression2538);
                    	boolExpression();
                    	state.followingStackPointer--;
                    	if (state.failed) return retval;

                    	Match(input, Token.UP, null); if (state.failed) return retval;
                    	if ( (state.backtracking==0) )
                    	{
                    	   retval.t =  SymbolTable.Boolean; cg.ExprAnd(); 
                    	}

                    }
                    break;
                case 23 :
                    // C:\\work\\simsharp\\Src\\Ssc\\SimSharpGen.g:1022:4: ^( OR boolExpression boolExpression )
                    {
                    	Match(input,OR,FOLLOW_OR_in_expression2547); if (state.failed) return retval;

                    	Match(input, Token.DOWN, null); if (state.failed) return retval;
                    	PushFollow(FOLLOW_boolExpression_in_expression2549);
                    	boolExpression();
                    	state.followingStackPointer--;
                    	if (state.failed) return retval;
                    	PushFollow(FOLLOW_boolExpression_in_expression2551);
                    	boolExpression();
                    	state.followingStackPointer--;
                    	if (state.failed) return retval;

                    	Match(input, Token.UP, null); if (state.failed) return retval;
                    	if ( (state.backtracking==0) )
                    	{
                    	   retval.t =  SymbolTable.Boolean; cg.ExprOr(); 
                    	}

                    }
                    break;
                case 24 :
                    // C:\\work\\simsharp\\Src\\Ssc\\SimSharpGen.g:1023:4: ^( EQV boolExpression boolExpression )
                    {
                    	Match(input,EQV,FOLLOW_EQV_in_expression2560); if (state.failed) return retval;

                    	Match(input, Token.DOWN, null); if (state.failed) return retval;
                    	PushFollow(FOLLOW_boolExpression_in_expression2562);
                    	boolExpression();
                    	state.followingStackPointer--;
                    	if (state.failed) return retval;
                    	PushFollow(FOLLOW_boolExpression_in_expression2564);
                    	boolExpression();
                    	state.followingStackPointer--;
                    	if (state.failed) return retval;

                    	Match(input, Token.UP, null); if (state.failed) return retval;
                    	if ( (state.backtracking==0) )
                    	{
                    	   retval.t =  SymbolTable.Boolean; cg.ExprEqv(); 
                    	}

                    }
                    break;
                case 25 :
                    // C:\\work\\simsharp\\Src\\Ssc\\SimSharpGen.g:1024:4: ^( IMP boolExpression boolExpression )
                    {
                    	Match(input,IMP,FOLLOW_IMP_in_expression2573); if (state.failed) return retval;

                    	Match(input, Token.DOWN, null); if (state.failed) return retval;
                    	PushFollow(FOLLOW_boolExpression_in_expression2575);
                    	boolExpression();
                    	state.followingStackPointer--;
                    	if (state.failed) return retval;
                    	PushFollow(FOLLOW_boolExpression_in_expression2577);
                    	boolExpression();
                    	state.followingStackPointer--;
                    	if (state.failed) return retval;

                    	Match(input, Token.UP, null); if (state.failed) return retval;
                    	if ( (state.backtracking==0) )
                    	{
                    	   retval.t =  SymbolTable.Boolean; cg.ExprImp(); 
                    	}

                    }
                    break;
                case 26 :
                    // C:\\work\\simsharp\\Src\\Ssc\\SimSharpGen.g:1025:4: andThen
                    {
                    	PushFollow(FOLLOW_andThen_in_expression2585);
                    	andThen();
                    	state.followingStackPointer--;
                    	if (state.failed) return retval;
                    	if ( (state.backtracking==0) )
                    	{
                    	   retval.t =  SymbolTable.Boolean; 
                    	}

                    }
                    break;
                case 27 :
                    // C:\\work\\simsharp\\Src\\Ssc\\SimSharpGen.g:1026:4: orElse
                    {
                    	PushFollow(FOLLOW_orElse_in_expression2592);
                    	orElse();
                    	state.followingStackPointer--;
                    	if (state.failed) return retval;
                    	if ( (state.backtracking==0) )
                    	{
                    	   retval.t =  SymbolTable.Boolean; 
                    	}

                    }
                    break;
                case 28 :
                    // C:\\work\\simsharp\\Src\\Ssc\\SimSharpGen.g:1027:4: ^( QUA o= objectExpression c= classId )
                    {
                    	Match(input,QUA,FOLLOW_QUA_in_expression2601); if (state.failed) return retval;

                    	Match(input, Token.DOWN, null); if (state.failed) return retval;
                    	PushFollow(FOLLOW_objectExpression_in_expression2605);
                    	o = objectExpression();
                    	state.followingStackPointer--;
                    	if (state.failed) return retval;
                    	PushFollow(FOLLOW_classId_in_expression2609);
                    	c = classId();
                    	state.followingStackPointer--;
                    	if (state.failed) return retval;

                    	Match(input, Token.UP, null); if (state.failed) return retval;
                    	if ( (state.backtracking==0) )
                    	{
                    	   retval.t =  ((c != null) ? c.type : default(TypeSymbol)); cg.TypeConvert(o, ((c != null) ? c.type : default(TypeSymbol))); 
                    	}

                    }
                    break;
                case 29 :
                    // C:\\work\\simsharp\\Src\\Ssc\\SimSharpGen.g:1028:4: ^( THIS c= classId )
                    {
                    	Match(input,THIS,FOLLOW_THIS_in_expression2618); if (state.failed) return retval;

                    	Match(input, Token.DOWN, null); if (state.failed) return retval;
                    	PushFollow(FOLLOW_classId_in_expression2622);
                    	c = classId();
                    	state.followingStackPointer--;
                    	if (state.failed) return retval;

                    	Match(input, Token.UP, null); if (state.failed) return retval;
                    	if ( (state.backtracking==0) )
                    	{
                    	   retval.t =  ((c != null) ? c.type : default(TypeSymbol)); cg.LoadThis(); cg.TypeConvert(ctx.CurrentType, ((c != null) ? c.type : default(TypeSymbol))); 
                    	}

                    }
                    break;

            }
        }
        catch (RecognitionException re) 
    	{
            ReportError(re);
            Recover(input,re);
        }
        finally 
    	{
        }
        return retval;
    }
    // $ANTLR end "expression"


    // $ANTLR start "andThen"
    // C:\\work\\simsharp\\Src\\Ssc\\SimSharpGen.g:1031:1: andThen : ^( AndThen boolExpression boolExpression ) ;
    public void andThen() // throws RecognitionException [1]
    {   

        LabelSymbol labelEnd = null;

        try 
    	{
            // C:\\work\\simsharp\\Src\\Ssc\\SimSharpGen.g:1035:2: ( ^( AndThen boolExpression boolExpression ) )
            // C:\\work\\simsharp\\Src\\Ssc\\SimSharpGen.g:1035:4: ^( AndThen boolExpression boolExpression )
            {
            	Match(input,AndThen,FOLLOW_AndThen_in_andThen2643); if (state.failed) return ;

            	Match(input, Token.DOWN, null); if (state.failed) return ;
            	PushFollow(FOLLOW_boolExpression_in_andThen2648);
            	boolExpression();
            	state.followingStackPointer--;
            	if (state.failed) return ;
            	if ( (state.backtracking==0) )
            	{

            	  		LabelSymbol labelNext = cg.DefineJumpPoint();
            	  		cg.BranchIfTrue(labelNext);
            	  		cg.LoadConst(0);
            	  		labelEnd = cg.GotoJumpPoint();
            	  		
            	  		cg.SetJumpPoint(labelNext);
            	  		
            	}
            	PushFollow(FOLLOW_boolExpression_in_andThen2657);
            	boolExpression();
            	state.followingStackPointer--;
            	if (state.failed) return ;
            	if ( (state.backtracking==0) )
            	{

            	  		cg.SetJumpPoint(labelEnd);
            	  		
            	}

            	Match(input, Token.UP, null); if (state.failed) return ;

            }

        }
        catch (RecognitionException re) 
    	{
            ReportError(re);
            Recover(input,re);
        }
        finally 
    	{
        }
        return ;
    }
    // $ANTLR end "andThen"


    // $ANTLR start "orElse"
    // C:\\work\\simsharp\\Src\\Ssc\\SimSharpGen.g:1052:1: orElse : ^( OrElse boolExpression boolExpression ) ;
    public void orElse() // throws RecognitionException [1]
    {   

        LabelSymbol labelEnd = null;

        try 
    	{
            // C:\\work\\simsharp\\Src\\Ssc\\SimSharpGen.g:1056:2: ( ^( OrElse boolExpression boolExpression ) )
            // C:\\work\\simsharp\\Src\\Ssc\\SimSharpGen.g:1056:4: ^( OrElse boolExpression boolExpression )
            {
            	Match(input,OrElse,FOLLOW_OrElse_in_orElse2686); if (state.failed) return ;

            	Match(input, Token.DOWN, null); if (state.failed) return ;
            	PushFollow(FOLLOW_boolExpression_in_orElse2691);
            	boolExpression();
            	state.followingStackPointer--;
            	if (state.failed) return ;
            	if ( (state.backtracking==0) )
            	{

            	  		LabelSymbol labelNext = cg.DefineJumpPoint();
            	  		cg.BranchIfFalse(labelNext);
            	  		cg.LoadConst(1);
            	  		labelEnd = cg.GotoJumpPoint();
            	  		
            	  		cg.SetJumpPoint(labelNext);
            	  		
            	}
            	PushFollow(FOLLOW_boolExpression_in_orElse2700);
            	boolExpression();
            	state.followingStackPointer--;
            	if (state.failed) return ;
            	if ( (state.backtracking==0) )
            	{

            	  		cg.SetJumpPoint(labelEnd);
            	  		
            	}

            	Match(input, Token.UP, null); if (state.failed) return ;

            }

        }
        catch (RecognitionException re) 
    	{
            ReportError(re);
            Recover(input,re);
        }
        finally 
    	{
        }
        return ;
    }
    // $ANTLR end "orElse"

    public class objectGenerator_return : TreeRuleReturnScope
    {
    };

    // $ANTLR start "objectGenerator"
    // C:\\work\\simsharp\\Src\\Ssc\\SimSharpGen.g:1073:1: objectGenerator : ^( NEW i= ID ( actualParams[c] )? ) ;
    public SimSharpGen.objectGenerator_return objectGenerator() // throws RecognitionException [1]
    {   
        SimSharpGen.objectGenerator_return retval = new SimSharpGen.objectGenerator_return();
        retval.Start = input.LT(1);

        SimSharpTreeNode i = null;
        SimSharpTreeNode NEW7 = null;


        CtorSymbol c = null;
        TypeSymbol t = null;

        try 
    	{
            // C:\\work\\simsharp\\Src\\Ssc\\SimSharpGen.g:1078:2: ( ^( NEW i= ID ( actualParams[c] )? ) )
            // C:\\work\\simsharp\\Src\\Ssc\\SimSharpGen.g:1078:4: ^( NEW i= ID ( actualParams[c] )? )
            {
            	NEW7=(SimSharpTreeNode)Match(input,NEW,FOLLOW_NEW_in_objectGenerator2729); if (state.failed) return retval;

            	Match(input, Token.DOWN, null); if (state.failed) return retval;
            	i=(SimSharpTreeNode)Match(input,ID,FOLLOW_ID_in_objectGenerator2736); if (state.failed) return retval;
            	if ( (state.backtracking==0) )
            	{
            	   
            	  		t = ctx.Scope.ResolveType(i.Text);
            	  		c = t.GetCtor();
            	  		if (c.Args.Count > 0)
            	  		{
            	  		  ArgumentSymbol arg = c.GetArgument(0);
            	  		  if (arg.Name == "_outer") 
            	  		  {
            	  		    if (arg.Type == ctx.CurrentType) cg.LoadThis();
            	  		    else if (arg.Type == ctx.CurrentType.Scope) cg.LoadOuter();
            	  		    else errMan.ReportError("CodeGen", i.Line, i.CharPositionInLine, "Unknown outer for class '" + t.Name + "'.");
            	  		  }
            	  		}
            	  		
            	}
            	// C:\\work\\simsharp\\Src\\Ssc\\SimSharpGen.g:1094:3: ( actualParams[c] )?
            	int alt44 = 2;
            	int LA44_0 = input.LA(1);

            	if ( (LA44_0 == ActualParameters) )
            	{
            	    alt44 = 1;
            	}
            	switch (alt44) 
            	{
            	    case 1 :
            	        // C:\\work\\simsharp\\Src\\Ssc\\SimSharpGen.g:1094:3: actualParams[c]
            	        {
            	        	PushFollow(FOLLOW_actualParams_in_objectGenerator2745);
            	        	actualParams(c);
            	        	state.followingStackPointer--;
            	        	if (state.failed) return retval;

            	        }
            	        break;

            	}

            	if ( (state.backtracking==0) )
            	{

            	  		cg.NewObject(c);
            	  		NEW7.ExprType = t;
            	  		
            	}

            	Match(input, Token.UP, null); if (state.failed) return retval;

            }

        }
        catch (RecognitionException re) 
    	{
            ReportError(re);
            Recover(input,re);
        }
        finally 
    	{
        }
        return retval;
    }
    // $ANTLR end "objectGenerator"


    // $ANTLR start "remoteAssign"
    // C:\\work\\simsharp\\Src\\Ssc\\SimSharpGen.g:1102:1: remoteAssign : ^( RemoteAssign e= refExpression a= assignableId ) ;
    public void remoteAssign() // throws RecognitionException [1]
    {   
        SimSharpTreeNode RemoteAssign8 = null;
        TypeSymbol e = default(TypeSymbol);

        SimSharpGen.assignableId_return a = default(SimSharpGen.assignableId_return);


        try 
    	{
            // C:\\work\\simsharp\\Src\\Ssc\\SimSharpGen.g:1103:2: ( ^( RemoteAssign e= refExpression a= assignableId ) )
            // C:\\work\\simsharp\\Src\\Ssc\\SimSharpGen.g:1103:4: ^( RemoteAssign e= refExpression a= assignableId )
            {
            	RemoteAssign8=(SimSharpTreeNode)Match(input,RemoteAssign,FOLLOW_RemoteAssign_in_remoteAssign2769); if (state.failed) return ;

            	Match(input, Token.DOWN, null); if (state.failed) return ;
            	PushFollow(FOLLOW_refExpression_in_remoteAssign2776);
            	e = refExpression();
            	state.followingStackPointer--;
            	if (state.failed) return ;
            	if ( (state.backtracking==0) )
            	{

            	   		ctx.Push(ctx.Scope.ResolveType(e.Name), true);
            	   		
            	}
            	PushFollow(FOLLOW_assignableId_in_remoteAssign2789);
            	a = assignableId();
            	state.followingStackPointer--;
            	if (state.failed) return ;
            	if ( (state.backtracking==0) )
            	{

            	   	  	RemoteAssign8.ExprType = ((a != null) ? ((SimSharpTreeNode)a.Start) : null).ExprType;
            	  	  	RemoteAssign8.Symbol = ((a != null) ? ((SimSharpTreeNode)a.Start) : null).Symbol;
            	  	  	ctx.Pop();
            	  	  	
            	}

            	Match(input, Token.UP, null); if (state.failed) return ;

            }

        }
        catch (RecognitionException re) 
    	{
            ReportError(re);
            Recover(input,re);
        }
        finally 
    	{
        }
        return ;
    }
    // $ANTLR end "remoteAssign"

    public class remote_return : TreeRuleReturnScope
    {
    };

    // $ANTLR start "remote"
    // C:\\work\\simsharp\\Src\\Ssc\\SimSharpGen.g:1117:1: remote : ^( RemoteAccess e= refExpression i= id ) ;
    public SimSharpGen.remote_return remote() // throws RecognitionException [1]
    {   
        SimSharpGen.remote_return retval = new SimSharpGen.remote_return();
        retval.Start = input.LT(1);

        SimSharpTreeNode RemoteAccess9 = null;
        TypeSymbol e = default(TypeSymbol);

        SimSharpGen.id_return i = default(SimSharpGen.id_return);


        try 
    	{
            // C:\\work\\simsharp\\Src\\Ssc\\SimSharpGen.g:1118:2: ( ^( RemoteAccess e= refExpression i= id ) )
            // C:\\work\\simsharp\\Src\\Ssc\\SimSharpGen.g:1118:4: ^( RemoteAccess e= refExpression i= id )
            {
            	RemoteAccess9=(SimSharpTreeNode)Match(input,RemoteAccess,FOLLOW_RemoteAccess_in_remote2813); if (state.failed) return retval;

            	Match(input, Token.DOWN, null); if (state.failed) return retval;
            	PushFollow(FOLLOW_refExpression_in_remote2821);
            	e = refExpression();
            	state.followingStackPointer--;
            	if (state.failed) return retval;
            	if ( (state.backtracking==0) )
            	{

            	   		ctx.Push(ctx.Scope.ResolveType(e.Name), true);
            	   		
            	}
            	PushFollow(FOLLOW_id_in_remote2837);
            	i = id();
            	state.followingStackPointer--;
            	if (state.failed) return retval;
            	if ( (state.backtracking==0) )
            	{

            	   	  	RemoteAccess9.ExprType = ((i != null) ? ((SimSharpTreeNode)i.Start) : null).ExprType;
            	   	  	ctx.Pop();
            	  		
            	}

            	Match(input, Token.UP, null); if (state.failed) return retval;

            }

        }
        catch (RecognitionException re) 
    	{
            ReportError(re);
            Recover(input,re);
        }
        finally 
    	{
        }
        return retval;
    }
    // $ANTLR end "remote"


    // $ANTLR start "actualParams"
    // C:\\work\\simsharp\\Src\\Ssc\\SimSharpGen.g:1131:1: actualParams[MethodSymbolBase m] : ^( ActualParameters (e= expression )* ) ;
    public void actualParams(MethodSymbolBase m) // throws RecognitionException [1]
    {   
        SimSharpGen.expression_return e = default(SimSharpGen.expression_return);



        object r = null;
        int n = 0;
        Stack<bool> oldLoadAsObject = new Stack<bool>();
        Stack<bool> oldLoadByRef = new Stack<bool>();
        int inc = 0;
        ArgumentSymbol arg = null;

        try 
    	{
            // C:\\work\\simsharp\\Src\\Ssc\\SimSharpGen.g:1140:2: ( ^( ActualParameters (e= expression )* ) )
            // C:\\work\\simsharp\\Src\\Ssc\\SimSharpGen.g:1141:4: ^( ActualParameters (e= expression )* )
            {
            	Match(input,ActualParameters,FOLLOW_ActualParameters_in_actualParams2871); if (state.failed) return ;

            	if ( (state.backtracking==0) )
            	{
            	  if (m is CtorSymbol && m.Args.Count > 1) inc = 1;
            	}

            	if ( input.LA(1) == Token.DOWN )
            	{
            	    Match(input, Token.DOWN, null); if (state.failed) return ;
            	    // C:\\work\\simsharp\\Src\\Ssc\\SimSharpGen.g:1143:5: (e= expression )*
            	    do 
            	    {
            	        int alt45 = 2;
            	        alt45 = dfa45.Predict(input);
            	        switch (alt45) 
            	    	{
            	    		case 1 :
            	    		    // C:\\work\\simsharp\\Src\\Ssc\\SimSharpGen.g:1144:6: e= expression
            	    		    {
            	    		    	if ( (state.backtracking==0) )
            	    		    	{

            	    		    	  	  		oldLoadAsObject.Push(this.loadAsObject);
            	    		    	  			oldLoadByRef.Push(this.loadByRef);
            	    		    	  			
            	    		    	  			r = ctx.PopRemotes(); 
            	    		    	  	  		this.loadAsObject = false;
            	    		    	  	  	        this.loadByRef = false;
            	    		    	  	  		if (m != null) 
            	    		    	  	  		{
            	    		    	  	  		  if ((n+inc) >= m.Args.Count) 
            	    		    	  	  		  {
            	    		    	  	  		    arg = null;
            	    		    	  	  		  }
            	    		    	  	  		  else
            	    		    	  	  		  {
            	    		    	  	  		    arg = m.GetArgument(n+inc);
            	    		    	  	  		    loadByRef =arg.NameParam;
            	    		    	  	  		  }
            	    		    	  	  		}
            	    		    	  	  		
            	    		    	}
            	    		    	PushFollow(FOLLOW_expression_in_actualParams2901);
            	    		    	e = expression();
            	    		    	state.followingStackPointer--;
            	    		    	if (state.failed) return ;
            	    		    	if ( (state.backtracking==0) )
            	    		    	{

            	    		    	  	  		if (m != null && arg != null)
            	    		    	  	  		{
            	    		    	  	  		  if (!cg.TypeConvert(((e != null) ? e.t : default(TypeSymbol)), arg.Type)) errMan.ReportError("CodeGen", ((e != null) ? ((SimSharpTreeNode)e.Start) : null).Line, ((e != null) ? ((SimSharpTreeNode)e.Start) : null).CharPositionInLine, 
            	    		    	  	  		    "Type mismatch parameter " + n+1 + ". Expected " + arg.Type.Name + ", found " + ((e != null) ? e.t : default(TypeSymbol)).Name + ".");
            	    		    	  	  		}
            	    		    	  	  		n++;
            	    		    	  	  		this.loadByRef = oldLoadByRef.Pop(); 
            	    		    	  	   		this.loadAsObject = oldLoadAsObject.Pop();
            	    		    	  	   		ctx.PushRemotes(r);
            	    		    	  	  		
            	    		    	}

            	    		    }
            	    		    break;

            	    		default:
            	    		    goto loop45;
            	        }
            	    } while (true);

            	    loop45:
            	    	;	// Stops C# compiler whining that label 'loop45' has no statements

            	    if ( (state.backtracking==0) )
            	    {

            	      	  	  if (m != null && m.Args.Count != (n + inc)) errMan.ReportError("CodeGen", ((e != null) ? ((SimSharpTreeNode)e.Start) : null).Line, ((e != null) ? ((SimSharpTreeNode)e.Start) : null).CharPositionInLine, 
            	      	  		    "Parameter count mismatch. Expected " + m.Args.Count + ", found " + n + ".");
            	      	  	
            	    }

            	    Match(input, Token.UP, null); if (state.failed) return ;
            	}
            	if ( (state.backtracking==0) )
            	{
            	   

            	  	   
            	}

            }

        }
        catch (RecognitionException re) 
    	{
            ReportError(re);
            Recover(input,re);
        }
        finally 
    	{
        }
        return ;
    }
    // $ANTLR end "actualParams"

    public class primary_return : TreeRuleReturnScope
    {
    };

    // $ANTLR start "primary"
    // C:\\work\\simsharp\\Src\\Ssc\\SimSharpGen.g:1187:1: primary : ( litteral | logicalValue | i= id );
    public SimSharpGen.primary_return primary() // throws RecognitionException [1]
    {   
        SimSharpGen.primary_return retval = new SimSharpGen.primary_return();
        retval.Start = input.LT(1);

        SimSharpGen.id_return i = default(SimSharpGen.id_return);


        try 
    	{
            // C:\\work\\simsharp\\Src\\Ssc\\SimSharpGen.g:1188:2: ( litteral | logicalValue | i= id )
            int alt46 = 3;
            alt46 = dfa46.Predict(input);
            switch (alt46) 
            {
                case 1 :
                    // C:\\work\\simsharp\\Src\\Ssc\\SimSharpGen.g:1188:4: litteral
                    {
                    	PushFollow(FOLLOW_litteral_in_primary2947);
                    	litteral();
                    	state.followingStackPointer--;
                    	if (state.failed) return retval;

                    }
                    break;
                case 2 :
                    // C:\\work\\simsharp\\Src\\Ssc\\SimSharpGen.g:1189:4: logicalValue
                    {
                    	PushFollow(FOLLOW_logicalValue_in_primary2952);
                    	logicalValue();
                    	state.followingStackPointer--;
                    	if (state.failed) return retval;

                    }
                    break;
                case 3 :
                    // C:\\work\\simsharp\\Src\\Ssc\\SimSharpGen.g:1190:4: i= id
                    {
                    	PushFollow(FOLLOW_id_in_primary2959);
                    	i = id();
                    	state.followingStackPointer--;
                    	if (state.failed) return retval;

                    }
                    break;

            }
        }
        catch (RecognitionException re) 
    	{
            ReportError(re);
            Recover(input,re);
        }
        finally 
    	{
        }
        return retval;
    }
    // $ANTLR end "primary"


    // $ANTLR start "litteral"
    // C:\\work\\simsharp\\Src\\Ssc\\SimSharpGen.g:1193:1: litteral : (c= CHARCONST | n= NUM_INT | r= NUM_REAL | s= STRING | n= NONE | t= NOTEXT );
    public void litteral() // throws RecognitionException [1]
    {   
        SimSharpTreeNode c = null;
        SimSharpTreeNode n = null;
        SimSharpTreeNode r = null;
        SimSharpTreeNode s = null;
        SimSharpTreeNode t = null;

        try 
    	{
            // C:\\work\\simsharp\\Src\\Ssc\\SimSharpGen.g:1193:9: (c= CHARCONST | n= NUM_INT | r= NUM_REAL | s= STRING | n= NONE | t= NOTEXT )
            int alt47 = 6;
            switch ( input.LA(1) ) 
            {
            case CHARCONST:
            	{
                alt47 = 1;
                }
                break;
            case NUM_INT:
            	{
                alt47 = 2;
                }
                break;
            case NUM_REAL:
            	{
                alt47 = 3;
                }
                break;
            case STRING:
            	{
                alt47 = 4;
                }
                break;
            case NONE:
            	{
                alt47 = 5;
                }
                break;
            case NOTEXT:
            	{
                alt47 = 6;
                }
                break;
            	default:
            	    if ( state.backtracking > 0 ) {state.failed = true; return ;}
            	    NoViableAltException nvae_d47s0 =
            	        new NoViableAltException("", 47, 0, input);

            	    throw nvae_d47s0;
            }

            switch (alt47) 
            {
                case 1 :
                    // C:\\work\\simsharp\\Src\\Ssc\\SimSharpGen.g:1193:11: c= CHARCONST
                    {
                    	c=(SimSharpTreeNode)Match(input,CHARCONST,FOLLOW_CHARCONST_in_litteral2971); if (state.failed) return ;
                    	if ( (state.backtracking==0) )
                    	{

                    	  	  Symbol sym = new LitteralSymbol(LitteralSymbol.Kind.CHAR, ((c != null) ? c.Text : null));   
                    	  	  c.Symbol = sym;
                    	  	  c.ExprType = sym.Type;
                    	  	  cg.Load(c.Symbol);
                    	  	  
                    	}

                    }
                    break;
                case 2 :
                    // C:\\work\\simsharp\\Src\\Ssc\\SimSharpGen.g:1200:4: n= NUM_INT
                    {
                    	n=(SimSharpTreeNode)Match(input,NUM_INT,FOLLOW_NUM_INT_in_litteral2983); if (state.failed) return ;
                    	if ( (state.backtracking==0) )
                    	{
                    	   
                    	  	  Symbol sym = new LitteralSymbol(LitteralSymbol.Kind.INT, ((n != null) ? n.Text : null));   
                    	  	  n.Symbol = sym;
                    	  	  n.ExprType = sym.Type;
                    	  	  cg.Load(n.Symbol);
                    	  	  
                    	}

                    }
                    break;
                case 3 :
                    // C:\\work\\simsharp\\Src\\Ssc\\SimSharpGen.g:1207:4: r= NUM_REAL
                    {
                    	r=(SimSharpTreeNode)Match(input,NUM_REAL,FOLLOW_NUM_REAL_in_litteral2999); if (state.failed) return ;
                    	if ( (state.backtracking==0) )
                    	{

                    	  	  Symbol sym = new LitteralSymbol(LitteralSymbol.Kind.REAL, ((r != null) ? r.Text : null));
                    	  	  r.Symbol = sym;
                    	  	  r.ExprType = sym.Type;
                    	  	  cg.Load(r.Symbol);
                    	  	  
                    	}

                    }
                    break;
                case 4 :
                    // C:\\work\\simsharp\\Src\\Ssc\\SimSharpGen.g:1214:4: s= STRING
                    {
                    	s=(SimSharpTreeNode)Match(input,STRING,FOLLOW_STRING_in_litteral3011); if (state.failed) return ;
                    	if ( (state.backtracking==0) )
                    	{

                    	  	  Symbol sym = new LitteralSymbol(LitteralSymbol.Kind.STRING, ((s != null) ? s.Text : null));
                    	  	  s.Symbol = sym;
                    	  	  s.ExprType = sym.Type;
                    	  	  cg.Load(s.Symbol);
                    	  	  //TODO: Load will implisitly convert the String to Text. We should consider doing this implisit convertion in TypeConvert rather than here.
                    	  	  s.Symbol.Type = SymbolTable.Text;
                    	  	  s.ExprType = SymbolTable.Text;
                    	  	  
                    	}

                    }
                    break;
                case 5 :
                    // C:\\work\\simsharp\\Src\\Ssc\\SimSharpGen.g:1224:4: n= NONE
                    {
                    	n=(SimSharpTreeNode)Match(input,NONE,FOLLOW_NONE_in_litteral3023); if (state.failed) return ;
                    	if ( (state.backtracking==0) )
                    	{

                    	  	  cg.LoadNull();
                    	  	  n.ExprType = SymbolTable.SimObject;
                    	  	  
                    	}

                    }
                    break;
                case 6 :
                    // C:\\work\\simsharp\\Src\\Ssc\\SimSharpGen.g:1229:4: t= NOTEXT
                    {
                    	t=(SimSharpTreeNode)Match(input,NOTEXT,FOLLOW_NOTEXT_in_litteral3035); if (state.failed) return ;
                    	if ( (state.backtracking==0) )
                    	{

                    	  	  Symbol sym = SymbolTable.NoText;
                    	  	  t.Symbol = sym;
                    	  	  t.ExprType = sym.Type;
                    	  	  cg.Load(sym);
                    	  	  
                    	}

                    }
                    break;

            }
        }
        catch (RecognitionException re) 
    	{
            ReportError(re);
            Recover(input,re);
        }
        finally 
    	{
        }
        return ;
    }
    // $ANTLR end "litteral"

    public class id_return : TreeRuleReturnScope
    {
    };

    // $ANTLR start "id"
    // C:\\work\\simsharp\\Src\\Ssc\\SimSharpGen.g:1238:1: id : ({...}?i= ID ( actualParams[m] )? | ( ID ActualParameters )=>i= ID actualParams[null] | i= ID );
    public SimSharpGen.id_return id() // throws RecognitionException [1]
    {   
        SimSharpGen.id_return retval = new SimSharpGen.id_return();
        retval.Start = input.LT(1);

        SimSharpTreeNode i = null;


        MethodSymbol m = null;
        Symbol s = null;

        try 
    	{
            // C:\\work\\simsharp\\Src\\Ssc\\SimSharpGen.g:1243:2: ({...}?i= ID ( actualParams[m] )? | ( ID ActualParameters )=>i= ID actualParams[null] | i= ID )
            int alt49 = 3;
            int LA49_0 = input.LA(1);

            if ( (LA49_0 == ID) )
            {
                int LA49_1 = input.LA(2);

                if ( ((IsMethod(((SimSharpTreeNode)retval.Start).Text))) )
                {
                    alt49 = 1;
                }
                else if ( (synpred2_SimSharpGen()) )
                {
                    alt49 = 2;
                }
                else if ( (true) )
                {
                    alt49 = 3;
                }
                else 
                {
                    if ( state.backtracking > 0 ) {state.failed = true; return retval;}
                    NoViableAltException nvae_d49s1 =
                        new NoViableAltException("", 49, 1, input);

                    throw nvae_d49s1;
                }
            }
            else 
            {
                if ( state.backtracking > 0 ) {state.failed = true; return retval;}
                NoViableAltException nvae_d49s0 =
                    new NoViableAltException("", 49, 0, input);

                throw nvae_d49s0;
            }
            switch (alt49) 
            {
                case 1 :
                    // C:\\work\\simsharp\\Src\\Ssc\\SimSharpGen.g:1243:4: {...}?i= ID ( actualParams[m] )?
                    {
                    	if ( !((IsMethod(((SimSharpTreeNode)retval.Start).Text))) ) 
                    	{
                    	    if ( state.backtracking > 0 ) {state.failed = true; return retval;}
                    	    throw new FailedPredicateException(input, "id", "IsMethod($start.Text)");
                    	}
                    	i=(SimSharpTreeNode)Match(input,ID,FOLLOW_ID_in_id3066); if (state.failed) return retval;
                    	if ( (state.backtracking==0) )
                    	{

                    	  	  m = ctx.Scope.ResolveMethod(((i != null) ? i.Text : null));
                    	  	  if (m != null)
                    	  	  {
                    	  	    if (!ctx.Remote) cg.LoadThisOrInspect(m);
                    	  	  }
                    	  	  else errMan.ReportError("CodeGen", i.Line, i.CharPositionInLine, "Unrecognized procedure '" + ((i != null) ? i.Text : null) + "'");
                    	  	  
                    	}
                    	// C:\\work\\simsharp\\Src\\Ssc\\SimSharpGen.g:1253:4: ( actualParams[m] )?
                    	int alt48 = 2;
                    	int LA48_0 = input.LA(1);

                    	if ( (LA48_0 == ActualParameters) )
                    	{
                    	    alt48 = 1;
                    	}
                    	switch (alt48) 
                    	{
                    	    case 1 :
                    	        // C:\\work\\simsharp\\Src\\Ssc\\SimSharpGen.g:1253:4: actualParams[m]
                    	        {
                    	        	PushFollow(FOLLOW_actualParams_in_id3078);
                    	        	actualParams(m);
                    	        	state.followingStackPointer--;
                    	        	if (state.failed) return retval;

                    	        }
                    	        break;

                    	}

                    	if ( (state.backtracking==0) )
                    	{

                    	  	  cg.CallMethod(m);
                    	  	  
                    	  	  s = null;
                    	  	  if (loadAsObject) s = cg.ConvertToObject(m.Type);  
                    	  	  if (s == null) s = m;
                    	  	  	    
                    	  	  i.Symbol = s;
                    	  	  i.ExprType = s.Type;
                    	  	  
                    	}

                    }
                    break;
                case 2 :
                    // C:\\work\\simsharp\\Src\\Ssc\\SimSharpGen.g:1264:4: ( ID ActualParameters )=>i= ID actualParams[null]
                    {
                    	i=(SimSharpTreeNode)Match(input,ID,FOLLOW_ID_in_id3103); if (state.failed) return retval;
                    	if ( (state.backtracking==0) )
                    	{

                    	  	  s = ctx.Scope.Resolve(((i != null) ? i.Text : null));
                    	  	  if (s == null) errMan.ReportError("CodeGen", i.Line, i.CharPositionInLine, "Unrecognized identifier '" + ((i != null) ? i.Text : null) + "'");
                    	  	  if (!s.Type.IsArray) errMan.ReportError("CodeGen", i.Line, i.CharPositionInLine, "'" + i.Text + "' is not an array.");
                    	  	  
                    	  	  if (!ctx.Remote) cg.LoadThisOrInspect(s);
                    	  	  cg.Load(s);
                    	  	  
                    	}
                    	PushFollow(FOLLOW_actualParams_in_id3113);
                    	actualParams(null);
                    	state.followingStackPointer--;
                    	if (state.failed) return retval;
                    	if ( (state.backtracking==0) )
                    	{

                    	  	  cg.Load(s.Type); //using symbol to ararys TypeSymbol in order to flag element loading
                    	  	  i.Symbol = s;
                    	  	  i.ExprType = s.Type.ElementType;
                    	  	  
                    	}

                    }
                    break;
                case 3 :
                    // C:\\work\\simsharp\\Src\\Ssc\\SimSharpGen.g:1280:4: i= ID
                    {
                    	i=(SimSharpTreeNode)Match(input,ID,FOLLOW_ID_in_id3126); if (state.failed) return retval;
                    	if ( (state.backtracking==0) )
                    	{

                    	  	  Symbol id = ctx.Scope.Resolve(((i != null) ? i.Text : null));
                    	  	  if (id != null)
                    	  	  {
                    	  	    if (!ctx.Remote) cg.LoadThisOrInspect(id); 
                    	  	    
                    	  	    if (loadByRef && !ctx.Remote) cg.LoadByRef(id);
                    	  	    else if (loadAsObject) cg.LoadAsObject(id);
                    	  	    else cg.Load(id);

                    	  	    i.Symbol = id;
                    	  	    i.ExprType = id.Type;	
                    	  	  }
                    	  	  else errMan.ReportError("CodeGen", i.Line, i.CharPositionInLine, "Unrecognized identifier '" + ((i != null) ? i.Text : null) + "'");
                    	  	  
                    	}

                    }
                    break;

            }
        }
        catch (RecognitionException re) 
    	{
            ReportError(re);
            Recover(input,re);
        }
        finally 
    	{
        }
        return retval;
    }
    // $ANTLR end "id"


    // $ANTLR start "logicalValue"
    // C:\\work\\simsharp\\Src\\Ssc\\SimSharpGen.g:1298:1: logicalValue : (b= TRUE | b= FALSE );
    public void logicalValue() // throws RecognitionException [1]
    {   
        SimSharpTreeNode b = null;

        try 
    	{
            // C:\\work\\simsharp\\Src\\Ssc\\SimSharpGen.g:1299:2: (b= TRUE | b= FALSE )
            int alt50 = 2;
            int LA50_0 = input.LA(1);

            if ( (LA50_0 == TRUE) )
            {
                alt50 = 1;
            }
            else if ( (LA50_0 == FALSE) )
            {
                alt50 = 2;
            }
            else 
            {
                if ( state.backtracking > 0 ) {state.failed = true; return ;}
                NoViableAltException nvae_d50s0 =
                    new NoViableAltException("", 50, 0, input);

                throw nvae_d50s0;
            }
            switch (alt50) 
            {
                case 1 :
                    // C:\\work\\simsharp\\Src\\Ssc\\SimSharpGen.g:1299:4: b= TRUE
                    {
                    	b=(SimSharpTreeNode)Match(input,TRUE,FOLLOW_TRUE_in_logicalValue3146); if (state.failed) return ;
                    	if ( (state.backtracking==0) )
                    	{
                    	   
                    	  	  Symbol sym = new LitteralSymbol(LitteralSymbol.Kind.BOOL, "true");   
                    	  	  b.Symbol = sym;
                    	  	  b.ExprType = sym.Type;
                    	  	  cg.Load(b.Symbol);
                    	  	  
                    	}

                    }
                    break;
                case 2 :
                    // C:\\work\\simsharp\\Src\\Ssc\\SimSharpGen.g:1306:4: b= FALSE
                    {
                    	b=(SimSharpTreeNode)Match(input,FALSE,FOLLOW_FALSE_in_logicalValue3160); if (state.failed) return ;
                    	if ( (state.backtracking==0) )
                    	{

                    	  	  Symbol sym = new LitteralSymbol(LitteralSymbol.Kind.BOOL, "false");   
                    	  	  b.Symbol = sym;
                    	  	  b.ExprType = sym.Type;
                    	  	  cg.Load(b.Symbol);
                    	  	  
                    	}

                    }
                    break;

            }
        }
        catch (RecognitionException re) 
    	{
            ReportError(re);
            Recover(input,re);
        }
        finally 
    	{
        }
        return ;
    }
    // $ANTLR end "logicalValue"

    // $ANTLR start "synpred1_SimSharpGen"
    public void synpred1_SimSharpGen_fragment() {
        // C:\\work\\simsharp\\Src\\Ssc\\SimSharpGen.g:881:4: ( ID ActualParameters )
        // C:\\work\\simsharp\\Src\\Ssc\\SimSharpGen.g:881:5: ID ActualParameters
        {
        	Match(input,ID,FOLLOW_ID_in_synpred1_SimSharpGen2018); if (state.failed) return ;
        	Match(input,ActualParameters,FOLLOW_ActualParameters_in_synpred1_SimSharpGen2020); if (state.failed) return ;

        }
    }
    // $ANTLR end "synpred1_SimSharpGen"

    // $ANTLR start "synpred2_SimSharpGen"
    public void synpred2_SimSharpGen_fragment() {
        // C:\\work\\simsharp\\Src\\Ssc\\SimSharpGen.g:1264:4: ( ID ActualParameters )
        // C:\\work\\simsharp\\Src\\Ssc\\SimSharpGen.g:1264:5: ID ActualParameters
        {
        	Match(input,ID,FOLLOW_ID_in_synpred2_SimSharpGen3091); if (state.failed) return ;
        	Match(input,ActualParameters,FOLLOW_ActualParameters_in_synpred2_SimSharpGen3093); if (state.failed) return ;

        }
    }
    // $ANTLR end "synpred2_SimSharpGen"

    // Delegated rules

   	public bool synpred1_SimSharpGen() 
   	{
   	    state.backtracking++;
   	    int start = input.Mark();
   	    try 
   	    {
   	        synpred1_SimSharpGen_fragment(); // can never throw exception
   	    }
   	    catch (RecognitionException re) 
   	    {
   	        Console.Error.WriteLine("impossible: "+re);
   	    }
   	    bool success = !state.failed;
   	    input.Rewind(start);
   	    state.backtracking--;
   	    state.failed = false;
   	    return success;
   	}
   	public bool synpred2_SimSharpGen() 
   	{
   	    state.backtracking++;
   	    int start = input.Mark();
   	    try 
   	    {
   	        synpred2_SimSharpGen_fragment(); // can never throw exception
   	    }
   	    catch (RecognitionException re) 
   	    {
   	        Console.Error.WriteLine("impossible: "+re);
   	    }
   	    bool success = !state.failed;
   	    input.Rewind(start);
   	    state.backtracking--;
   	    state.failed = false;
   	    return success;
   	}


   	protected DFA2 dfa2;
   	protected DFA41 dfa41;
   	protected DFA43 dfa43;
   	protected DFA45 dfa45;
   	protected DFA46 dfa46;
	private void InitializeCyclicDFAs()
	{
    	this.dfa2 = new DFA2(this);
    	this.dfa41 = new DFA41(this);
    	this.dfa43 = new DFA43(this);
    	this.dfa45 = new DFA45(this);
    	this.dfa46 = new DFA46(this);





	}

    const string DFA2_eotS =
        "\x0e\uffff";
    const string DFA2_eofS =
        "\x0e\uffff";
    const string DFA2_minS =
        "\x01\x06\x0d\uffff";
    const string DFA2_maxS =
        "\x01\x7f\x0d\uffff";
    const string DFA2_acceptS =
        "\x01\uffff\x01\x01\x01\x02\x01\x03\x01\x04\x01\x05\x01\x06\x01"+
        "\x07\x01\x08\x01\x09\x01\x0a\x01\x0b\x01\x0c\x01\x0d";
    const string DFA2_specialS =
        "\x0e\uffff}>";
    static readonly string[] DFA2_transitionS = {
            "\x01\x01\x0b\uffff\x01\x07\x06\uffff\x01\x05\x15\uffff\x01"+
            "\x0d\x01\x0c\x03\uffff\x01\x02\x10\uffff\x01\x03\x01\x04\x0f"+
            "\uffff\x01\x08\x01\uffff\x01\x09\x01\uffff\x01\x0a\x05\uffff"+
            "\x01\x06\x1e\uffff\x01\x0b",
            "",
            "",
            "",
            "",
            "",
            "",
            "",
            "",
            "",
            "",
            "",
            "",
            ""
    };

    static readonly short[] DFA2_eot = DFA.UnpackEncodedString(DFA2_eotS);
    static readonly short[] DFA2_eof = DFA.UnpackEncodedString(DFA2_eofS);
    static readonly char[] DFA2_min = DFA.UnpackEncodedStringToUnsignedChars(DFA2_minS);
    static readonly char[] DFA2_max = DFA.UnpackEncodedStringToUnsignedChars(DFA2_maxS);
    static readonly short[] DFA2_accept = DFA.UnpackEncodedString(DFA2_acceptS);
    static readonly short[] DFA2_special = DFA.UnpackEncodedString(DFA2_specialS);
    static readonly short[][] DFA2_transition = DFA.UnpackEncodedStringArray(DFA2_transitionS);

    protected class DFA2 : DFA
    {
        public DFA2(BaseRecognizer recognizer)
        {
            this.recognizer = recognizer;
            this.decisionNumber = 2;
            this.eot = DFA2_eot;
            this.eof = DFA2_eof;
            this.min = DFA2_min;
            this.max = DFA2_max;
            this.accept = DFA2_accept;
            this.special = DFA2_special;
            this.transition = DFA2_transition;

        }

        override public string Description
        {
            get { return "96:1: statement : ( block | prefixedBlock | valueAssignment | refAssignment[false] | procStatement | connection | compoundStatement | condition | whileStatement | forStatement | objectGenStatement | gotoStatement | labelStatement );"; }
        }

    }

    const string DFA41_eotS =
        "\x27\uffff";
    const string DFA41_eofS =
        "\x27\uffff";
    const string DFA41_minS =
        "\x01\x16\x26\uffff";
    const string DFA41_maxS =
        "\x01\u008a\x26\uffff";
    const string DFA41_acceptS =
        "\x01\uffff\x01\x01\x24\uffff\x01\x02";
    const string DFA41_specialS =
        "\x27\uffff}>";
    static readonly string[] DFA41_transitionS = {
            "\x01\x01\x0c\uffff\x01\x01\x09\uffff\x02\x01\x06\uffff\x03"+
            "\x01\x01\uffff\x03\x01\x01\uffff\x02\x01\x07\uffff\x01\x26\x02"+
            "\uffff\x02\x01\x01\uffff\x02\x01\x20\uffff\x13\x01\x08\uffff"+
            "\x02\x01",
            "",
            "",
            "",
            "",
            "",
            "",
            "",
            "",
            "",
            "",
            "",
            "",
            "",
            "",
            "",
            "",
            "",
            "",
            "",
            "",
            "",
            "",
            "",
            "",
            "",
            "",
            "",
            "",
            "",
            "",
            "",
            "",
            "",
            "",
            "",
            "",
            "",
            ""
    };

    static readonly short[] DFA41_eot = DFA.UnpackEncodedString(DFA41_eotS);
    static readonly short[] DFA41_eof = DFA.UnpackEncodedString(DFA41_eofS);
    static readonly char[] DFA41_min = DFA.UnpackEncodedStringToUnsignedChars(DFA41_minS);
    static readonly char[] DFA41_max = DFA.UnpackEncodedStringToUnsignedChars(DFA41_maxS);
    static readonly short[] DFA41_accept = DFA.UnpackEncodedString(DFA41_acceptS);
    static readonly short[] DFA41_special = DFA.UnpackEncodedString(DFA41_specialS);
    static readonly short[][] DFA41_transition = DFA.UnpackEncodedStringArray(DFA41_transitionS);

    protected class DFA41 : DFA
    {
        public DFA41(BaseRecognizer recognizer)
        {
            this.recognizer = recognizer;
            this.decisionNumber = 41;
            this.eot = DFA41_eot;
            this.eof = DFA41_eof;
            this.min = DFA41_min;
            this.max = DFA41_max;
            this.accept = DFA41_accept;
            this.special = DFA41_special;
            this.transition = DFA41_transition;

        }

        override public string Description
        {
            get { return "833:3: (s= expression | r= refAssignment[true] )"; }
        }

    }

    const string DFA43_eotS =
        "\x26\uffff";
    const string DFA43_eofS =
        "\x26\uffff";
    const string DFA43_minS =
        "\x01\x16\x25\uffff";
    const string DFA43_maxS =
        "\x01\u008a\x25\uffff";
    const string DFA43_acceptS =
        "\x01\uffff\x01\x01\x08\uffff\x01\x02\x01\x03\x01\x04\x01\x05\x01"+
        "\x06\x01\x07\x01\x08\x01\x09\x01\x0a\x01\x0b\x01\x0c\x01\x0d\x01"+
        "\x0e\x01\x0f\x01\x10\x01\x11\x01\x12\x01\x13\x01\x14\x01\x15\x01"+
        "\x16\x01\x17\x01\x18\x01\x19\x01\x1a\x01\x1b\x01\x1c\x01\x1d";
    const string DFA43_specialS =
        "\x26\uffff}>";
    static readonly string[] DFA43_transitionS = {
            "\x01\x18\x0c\uffff\x01\x17\x09\uffff\x01\x22\x01\x23\x06\uffff"+
            "\x01\x12\x01\x11\x01\x13\x01\uffff\x01\x14\x01\x15\x01\x0a\x01"+
            "\uffff\x01\x1b\x01\x1a\x0a\uffff\x01\x01\x01\x1d\x01\uffff\x01"+
            "\x0b\x01\x01\x20\uffff\x01\x1f\x01\x1e\x01\x20\x01\x21\x01\x16"+
            "\x01\x1c\x01\x0e\x01\x10\x01\x0f\x01\x0d\x01\x0c\x01\x24\x05"+
            "\x01\x01\x19\x01\x25\x08\uffff\x02\x01",
            "",
            "",
            "",
            "",
            "",
            "",
            "",
            "",
            "",
            "",
            "",
            "",
            "",
            "",
            "",
            "",
            "",
            "",
            "",
            "",
            "",
            "",
            "",
            "",
            "",
            "",
            "",
            "",
            "",
            "",
            "",
            "",
            "",
            "",
            "",
            "",
            ""
    };

    static readonly short[] DFA43_eot = DFA.UnpackEncodedString(DFA43_eotS);
    static readonly short[] DFA43_eof = DFA.UnpackEncodedString(DFA43_eofS);
    static readonly char[] DFA43_min = DFA.UnpackEncodedStringToUnsignedChars(DFA43_minS);
    static readonly char[] DFA43_max = DFA.UnpackEncodedStringToUnsignedChars(DFA43_maxS);
    static readonly short[] DFA43_accept = DFA.UnpackEncodedString(DFA43_acceptS);
    static readonly short[] DFA43_special = DFA.UnpackEncodedString(DFA43_specialS);
    static readonly short[][] DFA43_transition = DFA.UnpackEncodedStringArray(DFA43_transitionS);

    protected class DFA43 : DFA
    {
        public DFA43(BaseRecognizer recognizer)
        {
            this.recognizer = recognizer;
            this.decisionNumber = 43;
            this.eot = DFA43_eot;
            this.eof = DFA43_eof;
            this.min = DFA43_min;
            this.max = DFA43_max;
            this.accept = DFA43_accept;
            this.special = DFA43_special;
            this.transition = DFA43_transition;

        }

        override public string Description
        {
            get { return "998:1: expression returns [TypeSymbol t] : ( primary | ^( CONCAT x= expression y= expression ) | ^( EQ x= expression y= expression ) | ^( NE x= expression y= expression ) | ^( GT x= expression y= expression ) | ^( LT x= expression y= expression ) | ^( GE x= expression y= expression ) | ^( LE x= expression y= expression ) | ^( MINUS x= expression y= expression ) | ^( PLUS x= expression y= expression ) | ^( TIMES x= expression y= expression ) | ^( INTDIV expression expression ) | ^( EXP x= expression y= expression ) | ^( NOT expression ) | ^( Unary MINUS x= expression ) | remote | objectGenerator | ^( REFNEQ expression expression ) | ^( REFEQ expression expression ) | ^( IN objectExpression c= classId ) | ^( IS objectExpression c= classId ) | ^( AND boolExpression boolExpression ) | ^( OR boolExpression boolExpression ) | ^( EQV boolExpression boolExpression ) | ^( IMP boolExpression boolExpression ) | andThen | orElse | ^( QUA o= objectExpression c= classId ) | ^( THIS c= classId ) );"; }
        }

    }

    const string DFA45_eotS =
        "\x27\uffff";
    const string DFA45_eofS =
        "\x27\uffff";
    const string DFA45_minS =
        "\x01\x03\x26\uffff";
    const string DFA45_maxS =
        "\x01\u008a\x26\uffff";
    const string DFA45_acceptS =
        "\x01\uffff\x01\x02\x01\x01\x24\uffff";
    const string DFA45_specialS =
        "\x27\uffff}>";
    static readonly string[] DFA45_transitionS = {
            "\x01\x01\x12\uffff\x01\x02\x0c\uffff\x01\x02\x09\uffff\x02"+
            "\x02\x06\uffff\x03\x02\x01\uffff\x03\x02\x01\uffff\x02\x02\x0a"+
            "\uffff\x02\x02\x01\uffff\x02\x02\x20\uffff\x13\x02\x08\uffff"+
            "\x02\x02",
            "",
            "",
            "",
            "",
            "",
            "",
            "",
            "",
            "",
            "",
            "",
            "",
            "",
            "",
            "",
            "",
            "",
            "",
            "",
            "",
            "",
            "",
            "",
            "",
            "",
            "",
            "",
            "",
            "",
            "",
            "",
            "",
            "",
            "",
            "",
            "",
            "",
            ""
    };

    static readonly short[] DFA45_eot = DFA.UnpackEncodedString(DFA45_eotS);
    static readonly short[] DFA45_eof = DFA.UnpackEncodedString(DFA45_eofS);
    static readonly char[] DFA45_min = DFA.UnpackEncodedStringToUnsignedChars(DFA45_minS);
    static readonly char[] DFA45_max = DFA.UnpackEncodedStringToUnsignedChars(DFA45_maxS);
    static readonly short[] DFA45_accept = DFA.UnpackEncodedString(DFA45_acceptS);
    static readonly short[] DFA45_special = DFA.UnpackEncodedString(DFA45_specialS);
    static readonly short[][] DFA45_transition = DFA.UnpackEncodedStringArray(DFA45_transitionS);

    protected class DFA45 : DFA
    {
        public DFA45(BaseRecognizer recognizer)
        {
            this.recognizer = recognizer;
            this.decisionNumber = 45;
            this.eot = DFA45_eot;
            this.eof = DFA45_eof;
            this.min = DFA45_min;
            this.max = DFA45_max;
            this.accept = DFA45_accept;
            this.special = DFA45_special;
            this.transition = DFA45_transition;

        }

        override public string Description
        {
            get { return "()* loopback of 1143:5: (e= expression )*"; }
        }

    }

    const string DFA46_eotS =
        "\x0a\uffff";
    const string DFA46_eofS =
        "\x0a\uffff";
    const string DFA46_minS =
        "\x01\x49\x09\uffff";
    const string DFA46_maxS =
        "\x01\u008a\x09\uffff";
    const string DFA46_acceptS =
        "\x01\uffff\x01\x01\x05\uffff\x01\x02\x01\uffff\x01\x03";
    const string DFA46_specialS =
        "\x0a\uffff}>";
    static readonly string[] DFA46_transitionS = {
            "\x01\x09\x03\uffff\x01\x01\x2c\uffff\x05\x01\x0a\uffff\x02"+
            "\x07",
            "",
            "",
            "",
            "",
            "",
            "",
            "",
            "",
            ""
    };

    static readonly short[] DFA46_eot = DFA.UnpackEncodedString(DFA46_eotS);
    static readonly short[] DFA46_eof = DFA.UnpackEncodedString(DFA46_eofS);
    static readonly char[] DFA46_min = DFA.UnpackEncodedStringToUnsignedChars(DFA46_minS);
    static readonly char[] DFA46_max = DFA.UnpackEncodedStringToUnsignedChars(DFA46_maxS);
    static readonly short[] DFA46_accept = DFA.UnpackEncodedString(DFA46_acceptS);
    static readonly short[] DFA46_special = DFA.UnpackEncodedString(DFA46_specialS);
    static readonly short[][] DFA46_transition = DFA.UnpackEncodedStringArray(DFA46_transitionS);

    protected class DFA46 : DFA
    {
        public DFA46(BaseRecognizer recognizer)
        {
            this.recognizer = recognizer;
            this.decisionNumber = 46;
            this.eot = DFA46_eot;
            this.eof = DFA46_eof;
            this.min = DFA46_min;
            this.max = DFA46_max;
            this.accept = DFA46_accept;
            this.special = DFA46_special;
            this.transition = DFA46_transition;

        }

        override public string Description
        {
            get { return "1187:1: primary : ( litteral | logicalValue | i= id );"; }
        }

    }

 

    public static readonly BitSet FOLLOW_SimulaSourceModule_in_begin85 = new BitSet(new ulong[]{0x0000000000000004UL});
    public static readonly BitSet FOLLOW_program_in_begin87 = new BitSet(new ulong[]{0x0000000000000008UL});
    public static readonly BitSet FOLLOW_Program_in_program102 = new BitSet(new ulong[]{0x0000000000000004UL});
    public static readonly BitSet FOLLOW_programBody_in_program113 = new BitSet(new ulong[]{0x0000000000000008UL});
    public static readonly BitSet FOLLOW_block_in_programBody134 = new BitSet(new ulong[]{0x0000000000000002UL});
    public static readonly BitSet FOLLOW_compoundStatement_in_programBody139 = new BitSet(new ulong[]{0x0000000000000002UL});
    public static readonly BitSet FOLLOW_block_in_statement151 = new BitSet(new ulong[]{0x0000000000000002UL});
    public static readonly BitSet FOLLOW_prefixedBlock_in_statement156 = new BitSet(new ulong[]{0x0000000000000002UL});
    public static readonly BitSet FOLLOW_valueAssignment_in_statement161 = new BitSet(new ulong[]{0x0000000000000002UL});
    public static readonly BitSet FOLLOW_refAssignment_in_statement166 = new BitSet(new ulong[]{0x0000000000000002UL});
    public static readonly BitSet FOLLOW_procStatement_in_statement172 = new BitSet(new ulong[]{0x0000000000000002UL});
    public static readonly BitSet FOLLOW_connection_in_statement177 = new BitSet(new ulong[]{0x0000000000000002UL});
    public static readonly BitSet FOLLOW_compoundStatement_in_statement182 = new BitSet(new ulong[]{0x0000000000000002UL});
    public static readonly BitSet FOLLOW_condition_in_statement187 = new BitSet(new ulong[]{0x0000000000000002UL});
    public static readonly BitSet FOLLOW_whileStatement_in_statement192 = new BitSet(new ulong[]{0x0000000000000002UL});
    public static readonly BitSet FOLLOW_forStatement_in_statement197 = new BitSet(new ulong[]{0x0000000000000002UL});
    public static readonly BitSet FOLLOW_objectGenStatement_in_statement202 = new BitSet(new ulong[]{0x0000000000000002UL});
    public static readonly BitSet FOLLOW_gotoStatement_in_statement207 = new BitSet(new ulong[]{0x0000000000000002UL});
    public static readonly BitSet FOLLOW_labelStatement_in_statement212 = new BitSet(new ulong[]{0x0000000000000002UL});
    public static readonly BitSet FOLLOW_Label_in_labelStatement225 = new BitSet(new ulong[]{0x0000000000000004UL});
    public static readonly BitSet FOLLOW_ID_in_labelStatement229 = new BitSet(new ulong[]{0x0000000000000008UL});
    public static readonly BitSet FOLLOW_GoTo_in_gotoStatement248 = new BitSet(new ulong[]{0x0000000000000004UL});
    public static readonly BitSet FOLLOW_designationalExpression_in_gotoStatement250 = new BitSet(new ulong[]{0x0000000000000008UL});
    public static readonly BitSet FOLLOW_SwitchDesignator_in_designationalExpression264 = new BitSet(new ulong[]{0x0000000000000004UL});
    public static readonly BitSet FOLLOW_ID_in_designationalExpression271 = new BitSet(new ulong[]{0x6EE0600800400000UL,0xFFFFC00000003600UL,0x0000000000000601UL});
    public static readonly BitSet FOLLOW_expression_in_designationalExpression276 = new BitSet(new ulong[]{0x0000000000000008UL});
    public static readonly BitSet FOLLOW_LabelDesignator_in_designationalExpression293 = new BitSet(new ulong[]{0x0000000000000004UL});
    public static readonly BitSet FOLLOW_ID_in_designationalExpression299 = new BitSet(new ulong[]{0x0000000000000008UL});
    public static readonly BitSet FOLLOW_objectGenerator_in_objectGenStatement321 = new BitSet(new ulong[]{0x0000000000000002UL});
    public static readonly BitSet FOLLOW_FOR_in_forStatement343 = new BitSet(new ulong[]{0x0000000000000004UL});
    public static readonly BitSet FOLLOW_ID_in_forStatement350 = new BitSet(new ulong[]{0x0000000000000000UL,0x0000000000000060UL});
    public static readonly BitSet FOLLOW_forRightPart_in_forStatement359 = new BitSet(new ulong[]{0x0011800002040040UL,0x8000000105400060UL});
    public static readonly BitSet FOLLOW_statement_in_forStatement368 = new BitSet(new ulong[]{0x0000000000000008UL});
    public static readonly BitSet FOLLOW_VALASSIGN_in_forRightPart404 = new BitSet(new ulong[]{0x0000000000000004UL});
    public static readonly BitSet FOLLOW_forListElement_in_forRightPart421 = new BitSet(new ulong[]{0x0000000600000008UL});
    public static readonly BitSet FOLLOW_REFASSIGN_in_forRightPart443 = new BitSet(new ulong[]{0x0000000000000004UL});
    public static readonly BitSet FOLLOW_refForListElement_in_forRightPart457 = new BitSet(new ulong[]{0x0000000400000008UL});
    public static readonly BitSet FOLLOW_StepListElement_in_forListElement497 = new BitSet(new ulong[]{0x0000000000000004UL});
    public static readonly BitSet FOLLOW_expression_in_forListElement508 = new BitSet(new ulong[]{0x0000000000000000UL,0x0000000008000000UL});
    public static readonly BitSet FOLLOW_STEP_in_forListElement517 = new BitSet(new ulong[]{0x6EE0600800400000UL,0xFFFFC00000003600UL,0x0000000000000601UL});
    public static readonly BitSet FOLLOW_expression_in_forListElement527 = new BitSet(new ulong[]{0x6EE0600800400000UL,0xFFFFC00000003600UL,0x0000000000000601UL});
    public static readonly BitSet FOLLOW_expression_in_forListElement537 = new BitSet(new ulong[]{0x0000000000000000UL,0x0000000010000000UL});
    public static readonly BitSet FOLLOW_UNTIL_in_forListElement546 = new BitSet(new ulong[]{0x6EE0600800400000UL,0xFFFFC00000003600UL,0x0000000000000601UL});
    public static readonly BitSet FOLLOW_expression_in_forListElement551 = new BitSet(new ulong[]{0x0000000000000008UL});
    public static readonly BitSet FOLLOW_WhileListElement_in_forListElement567 = new BitSet(new ulong[]{0x0000000000000004UL});
    public static readonly BitSet FOLLOW_expression_in_forListElement578 = new BitSet(new ulong[]{0x0000000000000008UL});
    public static readonly BitSet FOLLOW_WhileListElement_in_refForListElement609 = new BitSet(new ulong[]{0x0000000000000004UL});
    public static readonly BitSet FOLLOW_expression_in_refForListElement620 = new BitSet(new ulong[]{0x0000000000000008UL});
    public static readonly BitSet FOLLOW_WHILE_in_whileStatement652 = new BitSet(new ulong[]{0x0000000000000004UL});
    public static readonly BitSet FOLLOW_expression_in_whileStatement667 = new BitSet(new ulong[]{0x0011800002040040UL,0x8000000105400060UL});
    public static readonly BitSet FOLLOW_statement_in_whileStatement676 = new BitSet(new ulong[]{0x0000000000000008UL});
    public static readonly BitSet FOLLOW_IF_in_condition708 = new BitSet(new ulong[]{0x0000000000000004UL});
    public static readonly BitSet FOLLOW_expression_in_condition713 = new BitSet(new ulong[]{0x0011800002040040UL,0x8000000105400060UL});
    public static readonly BitSet FOLLOW_statement_in_condition722 = new BitSet(new ulong[]{0x0011800002040048UL,0x8000000105400060UL});
    public static readonly BitSet FOLLOW_statement_in_condition739 = new BitSet(new ulong[]{0x0000000000000008UL});
    public static readonly BitSet FOLLOW_CompoundStatement_in_compoundStatement767 = new BitSet(new ulong[]{0x0000000000000004UL});
    public static readonly BitSet FOLLOW_statement_in_compoundStatement775 = new BitSet(new ulong[]{0x0011800002040048UL,0x8000000105400060UL});
    public static readonly BitSet FOLLOW_INSPECT_in_connection795 = new BitSet(new ulong[]{0x0000000000000004UL});
    public static readonly BitSet FOLLOW_expression_in_connection802 = new BitSet(new ulong[]{0x0000000008000000UL,0x0000000200000000UL});
    public static readonly BitSet FOLLOW_connect2_in_connection818 = new BitSet(new ulong[]{0x0000000000000008UL,0x0000000400000000UL});
    public static readonly BitSet FOLLOW_whenClause_in_connection844 = new BitSet(new ulong[]{0x0000000008000008UL,0x0000000600000000UL});
    public static readonly BitSet FOLLOW_otherwiseClause_in_connection863 = new BitSet(new ulong[]{0x0000000000000008UL});
    public static readonly BitSet FOLLOW_WHEN_in_whenClause893 = new BitSet(new ulong[]{0x0000000000000004UL});
    public static readonly BitSet FOLLOW_classId_in_whenClause900 = new BitSet(new ulong[]{0x0000000004000000UL});
    public static readonly BitSet FOLLOW_connect1_in_whenClause909 = new BitSet(new ulong[]{0x0000000000000008UL});
    public static readonly BitSet FOLLOW_OTHERWISE_in_otherwiseClause932 = new BitSet(new ulong[]{0x0000000000000004UL});
    public static readonly BitSet FOLLOW_statement_in_otherwiseClause934 = new BitSet(new ulong[]{0x0000000000000008UL});
    public static readonly BitSet FOLLOW_ConnectBlock1_in_connect1948 = new BitSet(new ulong[]{0x0000000000000004UL});
    public static readonly BitSet FOLLOW_statement_in_connect1950 = new BitSet(new ulong[]{0x0000000000000008UL});
    public static readonly BitSet FOLLOW_ConnectBlock2_in_connect2962 = new BitSet(new ulong[]{0x0000000000000004UL});
    public static readonly BitSet FOLLOW_statement_in_connect2964 = new BitSet(new ulong[]{0x0000000000000008UL});
    public static readonly BitSet FOLLOW_methCall_in_procStatement977 = new BitSet(new ulong[]{0x0000000000000002UL});
    public static readonly BitSet FOLLOW_MethCall_in_methCall991 = new BitSet(new ulong[]{0x0000000000000004UL});
    public static readonly BitSet FOLLOW_expression_in_methCall995 = new BitSet(new ulong[]{0x0000000000000008UL});
    public static readonly BitSet FOLLOW_Block_in_block1020 = new BitSet(new ulong[]{0x0000000000000004UL});
    public static readonly BitSet FOLLOW_declaration_in_block1028 = new BitSet(new ulong[]{0x0011809012040448UL,0x8000004105400060UL});
    public static readonly BitSet FOLLOW_statement_in_block1031 = new BitSet(new ulong[]{0x0011800002040048UL,0x8000000105400060UL});
    public static readonly BitSet FOLLOW_PrefixedBlock_in_prefixedBlock1053 = new BitSet(new ulong[]{0x0000000000000004UL});
    public static readonly BitSet FOLLOW_ID_in_prefixedBlock1058 = new BitSet(new ulong[]{0x0000000000000000UL,0x0000000000000200UL});
    public static readonly BitSet FOLLOW_ID_in_prefixedBlock1065 = new BitSet(new ulong[]{0x0000000000040040UL});
    public static readonly BitSet FOLLOW_block_in_prefixedBlock1077 = new BitSet(new ulong[]{0x0000000000000000UL,0x8000000000000000UL});
    public static readonly BitSet FOLLOW_compoundStatement_in_prefixedBlock1079 = new BitSet(new ulong[]{0x0000000000000000UL,0x8000000000000000UL});
    public static readonly BitSet FOLLOW_objectGenStatement_in_prefixedBlock1091 = new BitSet(new ulong[]{0x0000000000000008UL});
    public static readonly BitSet FOLLOW_varDecl_in_declaration1110 = new BitSet(new ulong[]{0x0000000000000002UL});
    public static readonly BitSet FOLLOW_procDecl_in_declaration1115 = new BitSet(new ulong[]{0x0000000000000002UL});
    public static readonly BitSet FOLLOW_classDecl_in_declaration1120 = new BitSet(new ulong[]{0x0000000000000002UL});
    public static readonly BitSet FOLLOW_arrayDecl_in_declaration1125 = new BitSet(new ulong[]{0x0000000000000002UL});
    public static readonly BitSet FOLLOW_switchDecl_in_declaration1130 = new BitSet(new ulong[]{0x0000000000000002UL});
    public static readonly BitSet FOLLOW_SWITCH_in_switchDecl1147 = new BitSet(new ulong[]{0x0000000000000004UL});
    public static readonly BitSet FOLLOW_ID_in_switchDecl1154 = new BitSet(new ulong[]{0x0008000000000000UL});
    public static readonly BitSet FOLLOW_switchList_in_switchDecl1163 = new BitSet(new ulong[]{0x0000000000000008UL});
    public static readonly BitSet FOLLOW_SwitchList_in_switchList1189 = new BitSet(new ulong[]{0x0000000000000004UL});
    public static readonly BitSet FOLLOW_ID_in_switchList1197 = new BitSet(new ulong[]{0x0000000000000008UL,0x0000000000000200UL});
    public static readonly BitSet FOLLOW_ArrayDecl_in_arrayDecl1226 = new BitSet(new ulong[]{0x0000000000000004UL});
    public static readonly BitSet FOLLOW_type_in_arrayDecl1229 = new BitSet(new ulong[]{0x0000010000000000UL});
    public static readonly BitSet FOLLOW_array_in_arrayDecl1233 = new BitSet(new ulong[]{0x0000010000000008UL});
    public static readonly BitSet FOLLOW_Array_in_array1254 = new BitSet(new ulong[]{0x0000000000000004UL});
    public static readonly BitSet FOLLOW_ID_in_array1261 = new BitSet(new ulong[]{0x0000020000000000UL});
    public static readonly BitSet FOLLOW_arrayDim_in_array1269 = new BitSet(new ulong[]{0x0000020000000008UL});
    public static readonly BitSet FOLLOW_ArrayDim_in_arrayDim1293 = new BitSet(new ulong[]{0x0000000000000004UL});
    public static readonly BitSet FOLLOW_expression_in_arrayDim1304 = new BitSet(new ulong[]{0x6EE0600800400000UL,0xFFFFC00000003600UL,0x0000000000000601UL});
    public static readonly BitSet FOLLOW_expression_in_arrayDim1315 = new BitSet(new ulong[]{0x0000000000000008UL});
    public static readonly BitSet FOLLOW_ClassDecl_in_classDecl1343 = new BitSet(new ulong[]{0x0000000000000004UL});
    public static readonly BitSet FOLLOW_ID_in_classDecl1345 = new BitSet(new ulong[]{0x0000000000000000UL,0x0000000000000800UL});
    public static readonly BitSet FOLLOW_CLASS_in_classDecl1348 = new BitSet(new ulong[]{0x0000000000000000UL,0x0000000000000200UL});
    public static readonly BitSet FOLLOW_ID_in_classDecl1355 = new BitSet(new ulong[]{0x00000020C0000000UL,0x0000020000000000UL});
    public static readonly BitSet FOLLOW_formalParameters_in_classDecl1367 = new BitSet(new ulong[]{0x00000020C0000000UL,0x0000020000000000UL});
    public static readonly BitSet FOLLOW_valueParams_in_classDecl1377 = new BitSet(new ulong[]{0x00000020C0000000UL,0x0000020000000000UL});
    public static readonly BitSet FOLLOW_specification_in_classDecl1386 = new BitSet(new ulong[]{0x00000020C0000000UL,0x0000020000000000UL});
    public static readonly BitSet FOLLOW_classBody_in_classDecl1392 = new BitSet(new ulong[]{0x0000000000000008UL});
    public static readonly BitSet FOLLOW_ClassBody_in_classBody1415 = new BitSet(new ulong[]{0x0000000000000004UL});
    public static readonly BitSet FOLLOW_prolog_in_classBody1417 = new BitSet(new ulong[]{0x0000100000000008UL});
    public static readonly BitSet FOLLOW_epilog_in_classBody1419 = new BitSet(new ulong[]{0x0000000000000008UL});
    public static readonly BitSet FOLLOW_Prolog_in_prolog1435 = new BitSet(new ulong[]{0x0000000000000004UL});
    public static readonly BitSet FOLLOW_declaration_in_prolog1444 = new BitSet(new ulong[]{0x0011809012040448UL,0x8000004105400060UL});
    public static readonly BitSet FOLLOW_statement_in_prolog1450 = new BitSet(new ulong[]{0x0011800002040048UL,0x8000000105400060UL});
    public static readonly BitSet FOLLOW_Epilog_in_epilog1474 = new BitSet(new ulong[]{0x0000000000000004UL});
    public static readonly BitSet FOLLOW_statement_in_epilog1483 = new BitSet(new ulong[]{0x0011800002040048UL,0x8000000105400060UL});
    public static readonly BitSet FOLLOW_VarDecl_in_varDecl1503 = new BitSet(new ulong[]{0x0000000000000004UL});
    public static readonly BitSet FOLLOW_type_in_varDecl1507 = new BitSet(new ulong[]{0x0000000000001000UL});
    public static readonly BitSet FOLLOW_TypeList_in_varDecl1514 = new BitSet(new ulong[]{0x0000000000000004UL});
    public static readonly BitSet FOLLOW_ID_in_varDecl1523 = new BitSet(new ulong[]{0x0000000000002008UL,0x0000000000000200UL});
    public static readonly BitSet FOLLOW_ConstElement_in_varDecl1537 = new BitSet(new ulong[]{0x0000000000000004UL});
    public static readonly BitSet FOLLOW_ID_in_varDecl1541 = new BitSet(new ulong[]{0x0000000000000000UL,0x1000000000000000UL});
    public static readonly BitSet FOLLOW_NUM_REAL_in_varDecl1545 = new BitSet(new ulong[]{0x0000000000000008UL});
    public static readonly BitSet FOLLOW_ProcDecl_in_procDecl1587 = new BitSet(new ulong[]{0x0000000000000004UL});
    public static readonly BitSet FOLLOW_type_in_procDecl1595 = new BitSet(new ulong[]{0x0000000000000000UL,0x0000000000000200UL});
    public static readonly BitSet FOLLOW_ID_in_procDecl1605 = new BitSet(new ulong[]{0x00000000E0000000UL,0x0000030000000000UL});
    public static readonly BitSet FOLLOW_formalParameters_in_procDecl1619 = new BitSet(new ulong[]{0x00000000E0000000UL,0x0000030000000000UL});
    public static readonly BitSet FOLLOW_nameParams_in_procDecl1629 = new BitSet(new ulong[]{0x00000000E0000000UL,0x0000030000000000UL});
    public static readonly BitSet FOLLOW_valueParams_in_procDecl1638 = new BitSet(new ulong[]{0x00000000E0000000UL,0x0000030000000000UL});
    public static readonly BitSet FOLLOW_specification_in_procDecl1647 = new BitSet(new ulong[]{0x00000000E0000000UL,0x0000030000000000UL});
    public static readonly BitSet FOLLOW_procBody_in_procDecl1655 = new BitSet(new ulong[]{0x0000000000000008UL});
    public static readonly BitSet FOLLOW_VALUE_in_valueParams1672 = new BitSet(new ulong[]{0x0000000000000004UL});
    public static readonly BitSet FOLLOW_ID_in_valueParams1679 = new BitSet(new ulong[]{0x0000000000000008UL,0x0000000000000200UL});
    public static readonly BitSet FOLLOW_NAME_in_nameParams1707 = new BitSet(new ulong[]{0x0000000000000004UL});
    public static readonly BitSet FOLLOW_ID_in_nameParams1709 = new BitSet(new ulong[]{0x0000000000000008UL,0x0000000000000200UL});
    public static readonly BitSet FOLLOW_FormalParameters_in_formalParameters1725 = new BitSet(new ulong[]{0x0000000000000004UL});
    public static readonly BitSet FOLLOW_ID_in_formalParameters1733 = new BitSet(new ulong[]{0x0000000000000008UL,0x0000000000000200UL});
    public static readonly BitSet FOLLOW_Specification_in_specification1761 = new BitSet(new ulong[]{0x0000000000000004UL});
    public static readonly BitSet FOLLOW_type_in_specification1771 = new BitSet(new ulong[]{0x0000000000000000UL,0x0000000000000200UL});
    public static readonly BitSet FOLLOW_ID_in_specification1777 = new BitSet(new ulong[]{0x0000000000000808UL,0x0000000000000200UL});
    public static readonly BitSet FOLLOW_ProcBody_in_procBody1807 = new BitSet(new ulong[]{0x0000000000000004UL});
    public static readonly BitSet FOLLOW_statement_in_procBody1809 = new BitSet(new ulong[]{0x0000000000000008UL});
    public static readonly BitSet FOLLOW_Type_in_type1823 = new BitSet(new ulong[]{0x0000000000000004UL});
    public static readonly BitSet FOLLOW_INTEGER_in_type1826 = new BitSet(new ulong[]{0x0000000000000008UL});
    public static readonly BitSet FOLLOW_TEXT_in_type1833 = new BitSet(new ulong[]{0x0000000000000008UL});
    public static readonly BitSet FOLLOW_REAL_in_type1842 = new BitSet(new ulong[]{0x0000000000000008UL});
    public static readonly BitSet FOLLOW_CHARACTER_in_type1850 = new BitSet(new ulong[]{0x0000000000000008UL});
    public static readonly BitSet FOLLOW_REF_in_type1857 = new BitSet(new ulong[]{0x0000000000000000UL,0x0000000000000200UL});
    public static readonly BitSet FOLLOW_ID_in_type1861 = new BitSet(new ulong[]{0x0000000000000008UL});
    public static readonly BitSet FOLLOW_BOOLEAN_in_type1868 = new BitSet(new ulong[]{0x0000000000000008UL});
    public static readonly BitSet FOLLOW_REFASSIGN_in_refAssignment1904 = new BitSet(new ulong[]{0x0000000000000004UL});
    public static readonly BitSet FOLLOW_lvalue_in_refAssignment1910 = new BitSet(new ulong[]{0x6EE0600800400000UL,0xFFFFC00000003640UL,0x0000000000000601UL});
    public static readonly BitSet FOLLOW_expression_in_refAssignment1921 = new BitSet(new ulong[]{0x0000000000000008UL});
    public static readonly BitSet FOLLOW_refAssignment_in_refAssignment1937 = new BitSet(new ulong[]{0x0000000000000008UL});
    public static readonly BitSet FOLLOW_VALASSIGN_in_valueAssignment1968 = new BitSet(new ulong[]{0x0000000000000004UL});
    public static readonly BitSet FOLLOW_lvalue_in_valueAssignment1978 = new BitSet(new ulong[]{0x6EE0600800400000UL,0xFFFFC00000003600UL,0x0000000000000601UL});
    public static readonly BitSet FOLLOW_expression_in_valueAssignment1991 = new BitSet(new ulong[]{0x0000000000000008UL});
    public static readonly BitSet FOLLOW_arrayAssign_in_lvalue2025 = new BitSet(new ulong[]{0x0000000000000002UL});
    public static readonly BitSet FOLLOW_assignableId_in_lvalue2032 = new BitSet(new ulong[]{0x0000000000000002UL});
    public static readonly BitSet FOLLOW_remoteAssign_in_lvalue2039 = new BitSet(new ulong[]{0x0000000000000002UL});
    public static readonly BitSet FOLLOW_ID_in_arrayAssign2060 = new BitSet(new ulong[]{0x0000000000080000UL});
    public static readonly BitSet FOLLOW_actualParams_in_arrayAssign2067 = new BitSet(new ulong[]{0x0000000000000002UL});
    public static readonly BitSet FOLLOW_ID_in_assignableId2086 = new BitSet(new ulong[]{0x0000000000000002UL});
    public static readonly BitSet FOLLOW_expression_in_refExpression2118 = new BitSet(new ulong[]{0x0000000000000002UL});
    public static readonly BitSet FOLLOW_expression_in_objectExpression2150 = new BitSet(new ulong[]{0x0000000000000002UL});
    public static readonly BitSet FOLLOW_expression_in_boolExpression2169 = new BitSet(new ulong[]{0x0000000000000002UL});
    public static readonly BitSet FOLLOW_ID_in_classId2194 = new BitSet(new ulong[]{0x0000000000000002UL});
    public static readonly BitSet FOLLOW_primary_in_expression2216 = new BitSet(new ulong[]{0x0000000000000002UL});
    public static readonly BitSet FOLLOW_CONCAT_in_expression2224 = new BitSet(new ulong[]{0x0000000000000004UL});
    public static readonly BitSet FOLLOW_expression_in_expression2228 = new BitSet(new ulong[]{0x6EE0600800400000UL,0xFFFFC00000003600UL,0x0000000000000601UL});
    public static readonly BitSet FOLLOW_expression_in_expression2232 = new BitSet(new ulong[]{0x0000000000000008UL});
    public static readonly BitSet FOLLOW_EQ_in_expression2241 = new BitSet(new ulong[]{0x0000000000000004UL});
    public static readonly BitSet FOLLOW_expression_in_expression2245 = new BitSet(new ulong[]{0x6EE0600800400000UL,0xFFFFC00000003600UL,0x0000000000000601UL});
    public static readonly BitSet FOLLOW_expression_in_expression2249 = new BitSet(new ulong[]{0x0000000000000008UL});
    public static readonly BitSet FOLLOW_NE_in_expression2258 = new BitSet(new ulong[]{0x0000000000000004UL});
    public static readonly BitSet FOLLOW_expression_in_expression2262 = new BitSet(new ulong[]{0x6EE0600800400000UL,0xFFFFC00000003600UL,0x0000000000000601UL});
    public static readonly BitSet FOLLOW_expression_in_expression2266 = new BitSet(new ulong[]{0x0000000000000008UL});
    public static readonly BitSet FOLLOW_GT_in_expression2275 = new BitSet(new ulong[]{0x0000000000000004UL});
    public static readonly BitSet FOLLOW_expression_in_expression2279 = new BitSet(new ulong[]{0x6EE0600800400000UL,0xFFFFC00000003600UL,0x0000000000000601UL});
    public static readonly BitSet FOLLOW_expression_in_expression2283 = new BitSet(new ulong[]{0x0000000000000008UL});
    public static readonly BitSet FOLLOW_LT_in_expression2292 = new BitSet(new ulong[]{0x0000000000000004UL});
    public static readonly BitSet FOLLOW_expression_in_expression2296 = new BitSet(new ulong[]{0x6EE0600800400000UL,0xFFFFC00000003600UL,0x0000000000000601UL});
    public static readonly BitSet FOLLOW_expression_in_expression2300 = new BitSet(new ulong[]{0x0000000000000008UL});
    public static readonly BitSet FOLLOW_GE_in_expression2309 = new BitSet(new ulong[]{0x0000000000000004UL});
    public static readonly BitSet FOLLOW_expression_in_expression2313 = new BitSet(new ulong[]{0x6EE0600800400000UL,0xFFFFC00000003600UL,0x0000000000000601UL});
    public static readonly BitSet FOLLOW_expression_in_expression2317 = new BitSet(new ulong[]{0x0000000000000008UL});
    public static readonly BitSet FOLLOW_LE_in_expression2326 = new BitSet(new ulong[]{0x0000000000000004UL});
    public static readonly BitSet FOLLOW_expression_in_expression2330 = new BitSet(new ulong[]{0x6EE0600800400000UL,0xFFFFC00000003600UL,0x0000000000000601UL});
    public static readonly BitSet FOLLOW_expression_in_expression2334 = new BitSet(new ulong[]{0x0000000000000008UL});
    public static readonly BitSet FOLLOW_MINUS_in_expression2343 = new BitSet(new ulong[]{0x0000000000000004UL});
    public static readonly BitSet FOLLOW_expression_in_expression2347 = new BitSet(new ulong[]{0x6EE0600800400000UL,0xFFFFC00000003600UL,0x0000000000000601UL});
    public static readonly BitSet FOLLOW_expression_in_expression2351 = new BitSet(new ulong[]{0x0000000000000008UL});
    public static readonly BitSet FOLLOW_PLUS_in_expression2360 = new BitSet(new ulong[]{0x0000000000000004UL});
    public static readonly BitSet FOLLOW_expression_in_expression2364 = new BitSet(new ulong[]{0x6EE0600800400000UL,0xFFFFC00000003600UL,0x0000000000000601UL});
    public static readonly BitSet FOLLOW_expression_in_expression2368 = new BitSet(new ulong[]{0x0000000000000008UL});
    public static readonly BitSet FOLLOW_TIMES_in_expression2377 = new BitSet(new ulong[]{0x0000000000000004UL});
    public static readonly BitSet FOLLOW_expression_in_expression2381 = new BitSet(new ulong[]{0x6EE0600800400000UL,0xFFFFC00000003600UL,0x0000000000000601UL});
    public static readonly BitSet FOLLOW_expression_in_expression2385 = new BitSet(new ulong[]{0x0000000000000008UL});
    public static readonly BitSet FOLLOW_INTDIV_in_expression2395 = new BitSet(new ulong[]{0x0000000000000004UL});
    public static readonly BitSet FOLLOW_expression_in_expression2397 = new BitSet(new ulong[]{0x6EE0600800400000UL,0xFFFFC00000003600UL,0x0000000000000601UL});
    public static readonly BitSet FOLLOW_expression_in_expression2399 = new BitSet(new ulong[]{0x0000000000000008UL});
    public static readonly BitSet FOLLOW_EXP_in_expression2409 = new BitSet(new ulong[]{0x0000000000000004UL});
    public static readonly BitSet FOLLOW_expression_in_expression2413 = new BitSet(new ulong[]{0x6EE0600800400000UL,0xFFFFC00000003600UL,0x0000000000000601UL});
    public static readonly BitSet FOLLOW_expression_in_expression2417 = new BitSet(new ulong[]{0x0000000000000008UL});
    public static readonly BitSet FOLLOW_NOT_in_expression2427 = new BitSet(new ulong[]{0x0000000000000004UL});
    public static readonly BitSet FOLLOW_expression_in_expression2429 = new BitSet(new ulong[]{0x0000000000000008UL});
    public static readonly BitSet FOLLOW_Unary_in_expression2439 = new BitSet(new ulong[]{0x0000000000000004UL});
    public static readonly BitSet FOLLOW_MINUS_in_expression2441 = new BitSet(new ulong[]{0x6EE0600800400000UL,0xFFFFC00000003600UL,0x0000000000000601UL});
    public static readonly BitSet FOLLOW_expression_in_expression2445 = new BitSet(new ulong[]{0x0000000000000008UL});
    public static readonly BitSet FOLLOW_remote_in_expression2455 = new BitSet(new ulong[]{0x0000000000000002UL});
    public static readonly BitSet FOLLOW_objectGenerator_in_expression2463 = new BitSet(new ulong[]{0x0000000000000002UL});
    public static readonly BitSet FOLLOW_REFNEQ_in_expression2471 = new BitSet(new ulong[]{0x0000000000000004UL});
    public static readonly BitSet FOLLOW_expression_in_expression2473 = new BitSet(new ulong[]{0x6EE0600800400000UL,0xFFFFC00000003600UL,0x0000000000000601UL});
    public static readonly BitSet FOLLOW_expression_in_expression2475 = new BitSet(new ulong[]{0x0000000000000008UL});
    public static readonly BitSet FOLLOW_REFEQ_in_expression2486 = new BitSet(new ulong[]{0x0000000000000004UL});
    public static readonly BitSet FOLLOW_expression_in_expression2488 = new BitSet(new ulong[]{0x6EE0600800400000UL,0xFFFFC00000003600UL,0x0000000000000601UL});
    public static readonly BitSet FOLLOW_expression_in_expression2490 = new BitSet(new ulong[]{0x0000000000000008UL});
    public static readonly BitSet FOLLOW_IN_in_expression2501 = new BitSet(new ulong[]{0x0000000000000004UL});
    public static readonly BitSet FOLLOW_objectExpression_in_expression2503 = new BitSet(new ulong[]{0x0000000000000000UL,0x0000000000000200UL});
    public static readonly BitSet FOLLOW_classId_in_expression2507 = new BitSet(new ulong[]{0x0000000000000008UL});
    public static readonly BitSet FOLLOW_IS_in_expression2516 = new BitSet(new ulong[]{0x0000000000000004UL});
    public static readonly BitSet FOLLOW_objectExpression_in_expression2518 = new BitSet(new ulong[]{0x0000000000000000UL,0x0000000000000200UL});
    public static readonly BitSet FOLLOW_classId_in_expression2525 = new BitSet(new ulong[]{0x0000000000000008UL});
    public static readonly BitSet FOLLOW_AND_in_expression2534 = new BitSet(new ulong[]{0x0000000000000004UL});
    public static readonly BitSet FOLLOW_boolExpression_in_expression2536 = new BitSet(new ulong[]{0x6EE0600800400000UL,0xFFFFC00000003600UL,0x0000000000000601UL});
    public static readonly BitSet FOLLOW_boolExpression_in_expression2538 = new BitSet(new ulong[]{0x0000000000000008UL});
    public static readonly BitSet FOLLOW_OR_in_expression2547 = new BitSet(new ulong[]{0x0000000000000004UL});
    public static readonly BitSet FOLLOW_boolExpression_in_expression2549 = new BitSet(new ulong[]{0x6EE0600800400000UL,0xFFFFC00000003600UL,0x0000000000000601UL});
    public static readonly BitSet FOLLOW_boolExpression_in_expression2551 = new BitSet(new ulong[]{0x0000000000000008UL});
    public static readonly BitSet FOLLOW_EQV_in_expression2560 = new BitSet(new ulong[]{0x0000000000000004UL});
    public static readonly BitSet FOLLOW_boolExpression_in_expression2562 = new BitSet(new ulong[]{0x6EE0600800400000UL,0xFFFFC00000003600UL,0x0000000000000601UL});
    public static readonly BitSet FOLLOW_boolExpression_in_expression2564 = new BitSet(new ulong[]{0x0000000000000008UL});
    public static readonly BitSet FOLLOW_IMP_in_expression2573 = new BitSet(new ulong[]{0x0000000000000004UL});
    public static readonly BitSet FOLLOW_boolExpression_in_expression2575 = new BitSet(new ulong[]{0x6EE0600800400000UL,0xFFFFC00000003600UL,0x0000000000000601UL});
    public static readonly BitSet FOLLOW_boolExpression_in_expression2577 = new BitSet(new ulong[]{0x0000000000000008UL});
    public static readonly BitSet FOLLOW_andThen_in_expression2585 = new BitSet(new ulong[]{0x0000000000000002UL});
    public static readonly BitSet FOLLOW_orElse_in_expression2592 = new BitSet(new ulong[]{0x0000000000000002UL});
    public static readonly BitSet FOLLOW_QUA_in_expression2601 = new BitSet(new ulong[]{0x0000000000000004UL});
    public static readonly BitSet FOLLOW_objectExpression_in_expression2605 = new BitSet(new ulong[]{0x0000000000000000UL,0x0000000000000200UL});
    public static readonly BitSet FOLLOW_classId_in_expression2609 = new BitSet(new ulong[]{0x0000000000000008UL});
    public static readonly BitSet FOLLOW_THIS_in_expression2618 = new BitSet(new ulong[]{0x0000000000000004UL});
    public static readonly BitSet FOLLOW_classId_in_expression2622 = new BitSet(new ulong[]{0x0000000000000008UL});
    public static readonly BitSet FOLLOW_AndThen_in_andThen2643 = new BitSet(new ulong[]{0x0000000000000004UL});
    public static readonly BitSet FOLLOW_boolExpression_in_andThen2648 = new BitSet(new ulong[]{0x6EE0600800400000UL,0xFFFFC00000003600UL,0x0000000000000601UL});
    public static readonly BitSet FOLLOW_boolExpression_in_andThen2657 = new BitSet(new ulong[]{0x0000000000000008UL});
    public static readonly BitSet FOLLOW_OrElse_in_orElse2686 = new BitSet(new ulong[]{0x0000000000000004UL});
    public static readonly BitSet FOLLOW_boolExpression_in_orElse2691 = new BitSet(new ulong[]{0x6EE0600800400000UL,0xFFFFC00000003600UL,0x0000000000000601UL});
    public static readonly BitSet FOLLOW_boolExpression_in_orElse2700 = new BitSet(new ulong[]{0x0000000000000008UL});
    public static readonly BitSet FOLLOW_NEW_in_objectGenerator2729 = new BitSet(new ulong[]{0x0000000000000004UL});
    public static readonly BitSet FOLLOW_ID_in_objectGenerator2736 = new BitSet(new ulong[]{0x0000000000080008UL});
    public static readonly BitSet FOLLOW_actualParams_in_objectGenerator2745 = new BitSet(new ulong[]{0x0000000000000008UL});
    public static readonly BitSet FOLLOW_RemoteAssign_in_remoteAssign2769 = new BitSet(new ulong[]{0x0000000000000004UL});
    public static readonly BitSet FOLLOW_refExpression_in_remoteAssign2776 = new BitSet(new ulong[]{0x0000000000000000UL,0x0000000000000200UL});
    public static readonly BitSet FOLLOW_assignableId_in_remoteAssign2789 = new BitSet(new ulong[]{0x0000000000000008UL});
    public static readonly BitSet FOLLOW_RemoteAccess_in_remote2813 = new BitSet(new ulong[]{0x0000000000000004UL});
    public static readonly BitSet FOLLOW_refExpression_in_remote2821 = new BitSet(new ulong[]{0x0000000000000000UL,0x7C00000000002200UL,0x0000000000000600UL});
    public static readonly BitSet FOLLOW_id_in_remote2837 = new BitSet(new ulong[]{0x0000000000000008UL});
    public static readonly BitSet FOLLOW_ActualParameters_in_actualParams2871 = new BitSet(new ulong[]{0x0000000000000004UL});
    public static readonly BitSet FOLLOW_expression_in_actualParams2901 = new BitSet(new ulong[]{0x6EE0600800400008UL,0xFFFFC00000003600UL,0x0000000000000601UL});
    public static readonly BitSet FOLLOW_litteral_in_primary2947 = new BitSet(new ulong[]{0x0000000000000002UL});
    public static readonly BitSet FOLLOW_logicalValue_in_primary2952 = new BitSet(new ulong[]{0x0000000000000002UL});
    public static readonly BitSet FOLLOW_id_in_primary2959 = new BitSet(new ulong[]{0x0000000000000002UL});
    public static readonly BitSet FOLLOW_CHARCONST_in_litteral2971 = new BitSet(new ulong[]{0x0000000000000002UL});
    public static readonly BitSet FOLLOW_NUM_INT_in_litteral2983 = new BitSet(new ulong[]{0x0000000000000002UL});
    public static readonly BitSet FOLLOW_NUM_REAL_in_litteral2999 = new BitSet(new ulong[]{0x0000000000000002UL});
    public static readonly BitSet FOLLOW_STRING_in_litteral3011 = new BitSet(new ulong[]{0x0000000000000002UL});
    public static readonly BitSet FOLLOW_NONE_in_litteral3023 = new BitSet(new ulong[]{0x0000000000000002UL});
    public static readonly BitSet FOLLOW_NOTEXT_in_litteral3035 = new BitSet(new ulong[]{0x0000000000000002UL});
    public static readonly BitSet FOLLOW_ID_in_id3066 = new BitSet(new ulong[]{0x0000000000080002UL});
    public static readonly BitSet FOLLOW_actualParams_in_id3078 = new BitSet(new ulong[]{0x0000000000000002UL});
    public static readonly BitSet FOLLOW_ID_in_id3103 = new BitSet(new ulong[]{0x0000000000080000UL});
    public static readonly BitSet FOLLOW_actualParams_in_id3113 = new BitSet(new ulong[]{0x0000000000000002UL});
    public static readonly BitSet FOLLOW_ID_in_id3126 = new BitSet(new ulong[]{0x0000000000000002UL});
    public static readonly BitSet FOLLOW_TRUE_in_logicalValue3146 = new BitSet(new ulong[]{0x0000000000000002UL});
    public static readonly BitSet FOLLOW_FALSE_in_logicalValue3160 = new BitSet(new ulong[]{0x0000000000000002UL});
    public static readonly BitSet FOLLOW_ID_in_synpred1_SimSharpGen2018 = new BitSet(new ulong[]{0x0000000000080000UL});
    public static readonly BitSet FOLLOW_ActualParameters_in_synpred1_SimSharpGen2020 = new BitSet(new ulong[]{0x0000000000000002UL});
    public static readonly BitSet FOLLOW_ID_in_synpred2_SimSharpGen3091 = new BitSet(new ulong[]{0x0000000000080000UL});
    public static readonly BitSet FOLLOW_ActualParameters_in_synpred2_SimSharpGen3093 = new BitSet(new ulong[]{0x0000000000000002UL});

}
